Created
May 2, 2022 21:40
-
-
Save chrisgoffinet/f55914ef5da5035e47e51c135064ffb9 to your computer and use it in GitHub Desktop.
aws access advisor
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
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 |
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
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