Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save eugenestarchenko/2f4c43a0936d5fcc71faed952b0c2bad to your computer and use it in GitHub Desktop.

Select an option

Save eugenestarchenko/2f4c43a0936d5fcc71faed952b0c2bad 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