Created
December 11, 2017 13:32
-
-
Save bashtoni/7804fef232288f2962b435ae056a54e0 to your computer and use it in GitHub Desktop.
Find when AWS access keys were last used
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 | |
for user in $(aws iam list-users --query 'Users[].UserName' --output text); do | |
for key in $(aws iam list-access-keys --user-name $user --query 'AccessKeyMetadata[].AccessKeyId' --output text); do | |
aws iam get-access-key-last-used --access-key-id $key --query '[UserName,AccessKeyLastUsed.LastUsedDate]' --output text | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment