Your audit tool takes 40 minutes across 17 regions. How do you get it under 5?
AdvancedScenarioAWS automation with boto3
Answer
Situation read → Sequential I/O across regions and services.
What I'd do →
- Run regions concurrently with
ThreadPoolExecutor, one boto3 Session per worker thread. - Within a region, run independent checks concurrently too, bounded per service.
- Replace per-resource calls with batch calls (
get_metric_data, filters). - Skip regions that are disabled or have no resources (
describe_regions). - Measure per-phase timings in logs to target the slowest part.
Why → The work is almost entirely network wait, which threads overlap well.
Interview tip → Mention Sessions not being thread-safe; it is a common follow-up.
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