You need to know which IAM permissions your Python tool needs. How do you find the minimum?
AdvancedScenarioAWS automation with boto3
Answer
Situation read → Least privilege for automation roles.
What I'd do →
- List every boto3 call in the code; map each to its IAM action (usually
service:OperationName, but not always, e.g.list_objects_v2iss3:ListBucket). - Run the test suite or a sandbox run with CloudTrail and use IAM Access Analyzer policy generation from the CloudTrail activity.
- Scope resources and conditions where the API supports it (tag conditions, specific ARNs).
- Document the policy in the README and keep it in Terraform.
Why → Generated policies from real activity are accurate; guessing leads to *.
Interview tip → Mention Access Analyzer policy generation by name.
More on AWS automation with boto3
You are asked to write a script that stops all dev EC2 instances at 8 PM and starts them at 8 AM. How do you build it?BeginnerA script that lists all S3 objects in a bucket reports 1,000 objects, but the console says there are 48,000. What happened, and how do you fix the script?BeginnerYou need to find and delete EBS snapshots older than 90 days, but some are used by AMIs and backup plans. How do you write it safely?IntermediateYour audit script hits `ThrottlingException` / `RequestLimitExceeded` when scanning large accounts. What do you change?AdvancedYou must audit 40 AWS accounts in an Organization from one script. How do you handle credentials?AdvancedA Lambda written in Python times out at 15 minutes while processing a big S3 prefix. What are your options?Advanced