Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS cli command to list all the IAM users with last activity for than 180 days ago

what aws-cli command should i execute to list all IAM users whose account had last activity more than 180 days ago.

Basically we have to filter all those resources so that we can delete their accounts later

like image 851
Njoi Avatar asked Oct 27 '25 03:10

Njoi


2 Answers

See How to find unused credentials.

Specifically with the awscli, use a combination of:

  • aws iam list-access-keys to get information about the access keys for a given user

  • aws iam get-access-key-last-used to see when a given access key was last used

like image 99
jarmod Avatar answered Oct 29 '25 21:10

jarmod


Check the script I wrote for the purpose for 90 days. You can change the parameter to 180 days and run it. Additionally, you would need to pass the AWS profile parameter from the ~/.aws/credentials file. IAM_Access_Keyage

like image 30
Vin Avatar answered Oct 29 '25 21:10

Vin