Created
May 9, 2019 15:35
-
-
Save stfnhh/310df87bf5af654d2b3a6516ab798a53 to your computer and use it in GitHub Desktop.
Bulk update Cognito user attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
POOL_ID="" | |
QUERY="" | |
REGION="" | |
ATTRIBUTES=( | |
"key:value" | |
"key2:value2" | |
) | |
function update_user_attributes { | |
aws cognito-idp admin-update-user-attributes \ | |
--user-pool-id $POOL_ID \ | |
--username $1 \ | |
--user-attributes Name=custom:$2,Value=\"$3\" \ | |
--region $REGION | |
} | |
aws cognito-idp list-users --user-pool-id $POOL_ID | jq -r ".Users[].Username | select(contains(\"$QUERY\"))" | | |
while read -r value; do | |
for attribute in "${ATTRIBUTES[@]}" ; do | |
update_user_attributes $value ${attribute%%:*} ${attribute##*:} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment