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 個回答
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
專家
已回答 4 個月前
profile picture
專家
Steve_M
已審閱 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南