Convenient way to see permissions used and resources accessed when running custom Python code

0

Hello,

I often find myself writing / testing custom Python code that accesses AWS resources via boto3. I test the code locally under my own credentials, which are typically very permissive. Later, if I deploy this code to a cloud service such as ECS, EKS, Lambda, etc. I have to ensure that I've given that service appropriate IAM permissions to perform the required actions. Presently this is a somewhat slow and painful iterative process, where I read through the code to just see all the boto3 methods it calls and what resources are touched, and then create the appropriate policy.

My question is this: is there any way to run my script on my dev machine and log the IAM permissions used and the resources touched, such that I can just reference that log for a comprehensive list of the resources and permissions needed (at least for that specific run of the script, understanding that things could change if some of the resources are dynamic). This might be a hook into boto3.

This would be a huge time-saver. Any tips appreciated.

Thanks! Andrei

1 Answer
2

Certainly. IAM access analyser can do this for you by reviewing cloudtrail events and providing a policy as an output.

IAM Access Analyzer generates IAM policies based on access activity in your AWS CloudTrail logs.

Please find some info here.

https://docs.aws.amazon.com/IAM/latest/UserGuide/what-is-access-analyzer.html

profile picture
EXPERT
answered 4 months ago
profile picture
EXPERT
Steve_M
reviewed 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions