Last active
November 2, 2023 20:30
-
-
Save jheerman/1a15a0a504a35eb99018d750c3f45c40 to your computer and use it in GitHub Desktop.
Get AWS roles where last usage is greater than specified date
This file contains 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
aws iam list-roles | jq -r '.Roles[].RoleName' | xargs -I % aws iam get-role --role-name % | jq --arg cutoff '2023-04-01T00:00' '.[] | select(.RoleLastUsed.LastUsedDate | . <= $cutoff ) | {RoleName: .RoleName, LastUsedDate: .RoleLastUsed.LastUsedDate}' | jq -s '.' > roles_last_used_april.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment