Skip to content

Instantly share code, notes, and snippets.

@stfnhh
Last active May 9, 2019 14:45
Show Gist options
  • Save stfnhh/e94e142b424203c3f2d32821748cb506 to your computer and use it in GitHub Desktop.
Save stfnhh/e94e142b424203c3f2d32821748cb506 to your computer and use it in GitHub Desktop.
Creates and confirms an AWS Cognito user with custom attributes
#!/bin/bash
CLIENT_ID=""
POOL_ID=""
JOBS=""
EMAIL=""
PASSWORD=""
REGION=""
ATTRIBUTES=(
"key:value"
"key:value"
)
aws cognito-idp sign-up \
--region us-east-1 \
--client-id $CLIENT_ID \
--username $EMAIL \
--password $PASSWORD \
--user-attributes Name=email,Value=$EMAIL
aws cognito-idp admin-confirm-sign-up \
--user-pool-id $POOL_ID \
--username $EMAIL \
--region $REGION
aws cognito-idp admin-update-user-attributes \
--user-pool-id $POOL_ID \
--username $EMAIL \
--user-attributes Name=email_verified,Value=true
for attribute in "${ATTRIBUTES[@]}" ; do
aws cognito-idp admin-update-user-attributes \
--user-pool-id $POOL_ID \
--username $EMAIL \
--user-attributes Name=custom:${attribute%%:*},Value=\"${attribute##*:}\" \
--region $REGION
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment