Last active
December 7, 2022 20:15
-
-
Save tsibley/1bc47241534cf615ddfb11214dcb4534 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
set -euo pipefail | |
group="${1:?usage: $(basename "$0") <group-name>}" | |
echo "# $group group" | |
echo | |
for role in owners editors viewers; do | |
echo "# $role" | |
aws cognito-idp list-users-in-group \ | |
--user-pool-id us-east-1_Cg5rcTged \ | |
--group-name ${group}/${role} \ | |
--query 'Users[]' \ | |
| jq --compact-output '.[]' \ | |
| while read -r record; do | |
<<<"$record" yq --yaml-output --arg role "$role" ' | |
def attr(name): .Attributes | map(select(.Name == name) | .Value) | .[0]?; | |
[{ | |
role: $role, | |
name: attr("name"), | |
email: attr("email"), | |
username: .Username, | |
mustExist: true, | |
}] | |
' | |
echo | |
done | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment