Created
July 27, 2020 17:17
-
-
Save amcginlay/1f9ab2c266b7a00a041a7c087445e469 to your computer and use it in GitHub Desktop.
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 | |
aws iam get-account-authorization-details --query "RoleDetailList[].[RoleLastUsed.LastUsedDate, RoleName]" --output text | sed -e 's/^None/1970-01-01T00:00:00+00:00/g' | sort | while read roledata; do | |
set $roledata; rolelastused=${1:0:10}; rolename=${2} | |
daysago=$((($(date +%s)-$(date -j -f "%Y-%m-%d" ${rolelastused} +%s))/86400)) | |
echo "${rolename} (used ${daysago} days ago)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment