Skip to content

Instantly share code, notes, and snippets.

@chrisgoffinet
Created May 2, 2022 21:40
Show Gist options
  • Save chrisgoffinet/f55914ef5da5035e47e51c135064ffb9 to your computer and use it in GitHub Desktop.
Save chrisgoffinet/f55914ef5da5035e47e51c135064ffb9 to your computer and use it in GitHub Desktop.
aws access advisor
aws iam generate-service-last-accessed-details \
--arn <arn> --granularity ACTION_LEVEL
# Get tne jobID
aws iam get-service-last-accessed-details --job-id <jobID> > output.json
import json
def main():
f = open('output.json')
data = json.load(f)
for x in data['ServicesLastAccessed']:
if x['ServiceNamespace'] == 'ec2':
for action in x['TrackedActionsLastAccessed']:
if 'LastAccessedTime' in action:
print(action['ActionName'])
f.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment