Last active
June 3, 2021 13:23
-
-
Save nonrational/def2d71622d25e4433a6 to your computer and use it in GitHub Desktop.
list IAM keys / identities (awscli, underscore-cli or jq)
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
for u in $(aws iam list-users | jq ".Users[].UserName" --raw-output); do | |
aws iam list-access-keys --user $u | jq '.AccessKeyMetadata[] | .UserName + ":" + .AccessKeyId' ; | |
done |
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
# list iam keys by user in an easily grepable format. | |
# easily find which identity matches a particular iam key | |
# requires underscore-cli | |
names=$(aws iam list-users | underscore flatten | underscore pluck "UserName" | tr -d '[],"') | |
for name in $names; do | |
keys=$(aws iam list-access-keys | underscore flatten | underscore pluck "AccessKeyId" | tr -d '[],"') | |
for key in $keys; do | |
echo "$name : $key" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment