I'm trying to check in AWS if a user has two access keys, and I'd like to know when one of the keys was disabled.
I've tried:
import boto3
iam = boto3.client('iam')
for user in iam.list_users()['Users']:
print(user)
res = iam.list_access_keys(UserName=user['UserName'])
print(res)
But it doesn't show me the information I need.
CodePudding user response:
You could try running these awscli
commands:
aws iam generate-credential-report | jq -r '.State'
And then
aws iam get-credential-report \
| jq -r '.Content' \
| base64 --decode > your_report.csv
This will give you the full report on your user's keys (last accessed, issued, rotated etc.) and a lot more.
Here's an overview of what's in the report.