Question #610
A developer uses an AWS Lambda function to create thumbnails for images uploaded to an Amazon S3 bucket. The Lambda function is triggered automatically for images stored under the /uploads/ prefix. The developer finds that some high-resolution images cause the Lambda function to time out. They want to implement a fallback using another Lambda function that resizes the images. Which solution meets these requirements with the LEAST development effort?
Set the image resize Lambda function as a destination of the thumbnail generator Lambda function for the events that fail processing.
Create an Amazon Simple Queue Service (Amazon SQS) queue. Set the SQS queue as a destination with an on-failure condition for the thumbnail generator Lambda function. Configure the image resize Lambda function to poll from the SQS queue.
Create an AWS Step Functions state machine that invokes the thumbnail generator Lambda function and uses the image resize Lambda function as a fallback. Create an Amazon EventBridge rule that matches events from the S3 bucket to invoke the state machine.
Create an Amazon Simple Notification Service (Amazon SNS) topic. Set the SNS topic as a destination with an on-failure condition for the thumbnail generator Lambda function. Subscribe the image resize Lambda function to the SNS topic.
Explanation
Answer A is correct because AWS Lambda allows configuring destinations for asynchronous invocations. By setting the image resize Lambda as an on-failure destination, any failed executions (e.g., timeouts or errors) from the thumbnail generator Lambda are automatically routed to the resize function. This approach requires no additional infrastructure (e.g., queues, topics, or state machines) and minimal code changes.
Why other options are incorrect:
- B: Using SQS adds complexity (queue setup, polling logic, and error handling).
- C: Step Functions and EventBridge introduce workflow orchestration overhead.
- D: SNS requires topic/subscription setup and message parsing.
Key Points:
1. Lambda Destinations handle failures natively with minimal configuration.
2. Direct integration between Lambda functions reduces development effort.
3. Avoids managing auxiliary services like SQS, SNS, or Step Functions.
Answer
The correct answer is: A