A Lambda written in Python times out at 15 minutes while processing a big S3 prefix. What are your options?
AdvancedScenarioAWS automation with boto3
Answer
Situation read → Lambda's hard maximum is 15 minutes; the job is too big for a single invocation.
What I'd do →
- Fan out: one Lambda lists keys and sends batches to SQS; worker Lambdas process batches concurrently.
- Or use Step Functions Distributed Map over the S3 prefix.
- Or move to a container job on ECS/Fargate or AWS Batch with no time limit.
- Optimize per item: reuse clients created outside the handler, parallelize I/O with threads.
Why → Lambda is designed for short, parallel work; long sequential jobs belong elsewhere.
Interview tip → Mention creating boto3 clients outside the handler so warm invocations reuse connections.
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?AdvancedYou are asked to tag every untagged resource in an account with `Owner=unknown`. What questions do you ask and how do you implement it?Intermediate