A developer needs to run code that automatically resizes images whenever a new file is uploaded to an Amazon S3 bucket. The function runs for less than 5 seconds per image. The team wants to avoid managing any servers. Which AWS service is BEST suited for this requirement?
- A. AWS Elastic Beanstalk
- B. AWS Lambda✓ Correct
- C. Amazon EC2 with Auto Scaling
- D. Amazon ECS on EC2 launch type
Explanation
AWS Lambda is the best fit. It is a serverless, event-driven compute service that can be triggered directly by S3 events (e.g., ObjectCreated). It requires no server management, scales automatically per invocation, and is billed only for the milliseconds of execution time — perfect for short, event-driven tasks like image resizing. EC2 with Auto Scaling requires provisioning and managing instances; the team would need to poll S3 for new files rather than receiving automatic triggers. ECS on EC2 launch type involves running containers on EC2 instances that the team must manage, which violates the no-server-management requirement. Elastic Beanstalk is a PaaS for long-running applications; it still provisions EC2 instances underneath and is not event-driven by nature.