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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인