Skip to content

Instantly share code, notes, and snippets.

@daniel-woods
Created September 9, 2018 10:18
Show Gist options
  • Save daniel-woods/3ea0392b735b0bc48dfc5d2bc6192f49 to your computer and use it in GitHub Desktop.
Save daniel-woods/3ea0392b735b0bc48dfc5d2bc6192f49 to your computer and use it in GitHub Desktop.
Check if a number exists in a Cognito User Pool
#!/usr/bin/python
import boto3
import json
# Query Parameters:
# Phone Number we need to look up
phone_num = "+xxxxxxxxxxxxx"
# In which User Pool?
userpool = 'xx-xxxx-x_xxxXXXxxx'
cognito = boto3.client("cognito-idp")
response = cognito.list_users(
UserPoolId=userpool,
AttributesToGet=[
'phone_number',
],
Filter="phone_number=\"{}\"".format(phone_num))
print("Number in userpool?")
print(response['Users'])
if response['Users']:
print(True)
else:
print(False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment