Skip to content

Instantly share code, notes, and snippets.

@anthonydahanne
Created March 23, 2022 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonydahanne/f55c3d33d7f8be8bfe07afa4f5cadab7 to your computer and use it in GitHub Desktop.
Save anthonydahanne/f55c3d33d7f8be8bfe07afa4f5cadab7 to your computer and use it in GitHub Desktop.
Retrieve last accessed services in AWS
#!/usr/bin/env bash
ARN=arn:aws:iam::xxx:user/xxx
JOB_ID=$(aws iam generate-service-last-accessed-details --arn $ARN --output=json | jq -r .JobId)
aws iam get-service-last-accessed-details --job-id $JOB_ID --output=json | jq '[.ServicesLastAccessed[] | select (.TotalAuthenticatedEntities | contains(1))] | sort_by(.LastAuthenticated)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment