Skip to content

Instantly share code, notes, and snippets.

@stfnhh
Created May 9, 2019 15:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stfnhh/310df87bf5af654d2b3a6516ab798a53 to your computer and use it in GitHub Desktop.
Save stfnhh/310df87bf5af654d2b3a6516ab798a53 to your computer and use it in GitHub Desktop.
Bulk update Cognito user attributes
#!/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