Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save luissantos/80ea2f64d30a1a524be7876040f3ef08 to your computer and use it in GitHub Desktop.
Save luissantos/80ea2f64d30a1a524be7876040f3ef08 to your computer and use it in GitHub Desktop.
Find all the keys and their associated user for a specific account
export PROFILE=XXXX
for USER in `aws --profile $PROFILE iam list-users --query 'Users[].UserName' --output text`
do
for KEY in `aws --profile $PROFILE iam list-access-keys --user-name "$USER" --query 'AccessKeyMetadata[].AccessKeyId' --output text`
do
echo $USER $KEY
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment