Skip to content

Instantly share code, notes, and snippets.

@daveslutzkin
Last active November 15, 2015 00:31
Show Gist options
  • Save daveslutzkin/41645691f81cb92da12d to your computer and use it in GitHub Desktop.
Save daveslutzkin/41645691f81cb92da12d to your computer and use it in GitHub Desktop.
AWS CLI show IAM groups and policies by user
for full_username in `aws iam list-users | jq '.Users[].UserName'`
do
username=`echo $full_username | tr -d '"'`
echo $username \\t groups `aws iam list-groups-for-user --user-name $username | jq '.Groups[].GroupName' | tr '\n' ',' | tr -d '"'` \\t policies `aws iam list-attached-user-policies --user-name $username | jq '.AttachedPolicies[].PolicyName' | tr '\n' ',' | tr -d '"'`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment