Q88 — AWS DVA-C02 Ch.2
Question 88 of 100 | ← Chapter 2
A developer is using an AWS Lambda function to generate thumbnails for personal photos uploaded to an Amazon S3 bucket. The Lambda function is automatically invoked for personal photos stored under the `/original/` S3 prefix. The developer notices that certain photos cause the Lambda function to time out. The developer wishes to implement a fallback mechanism using another Lambda function that resizes photos. Which solution meets these requirements with the least development effort?
- A. Configure the image-resizing Lambda function as the destination for failed events from the thumbnail-generator Lambda function.
- B. Create an Amazon Simple Queue Service (Amazon SQS) queue. Configure the SQS queue as the destination for failed invocations of the thumbnail-generator Lambda function. Configure the image-resizing Lambda function to poll the SQS queue. ✓
- C. Create an AWS Step Functions state machine that invokes the thumbnail-generator Lambda function and uses the image-resizing Lambda function as a fallback. Create an Amazon EventBridge rule matching S3 bucket events to invoke the state machine.
- D. Create an Amazon Simple Notification Service (Amazon SNS) topic. Configure the SNS topic as the destination for failed invocations of the thumbnail-generator Lambda function. Subscribe the image-resizing Lambda function to the SNS topic.
Correct Answer: B. Create an Amazon Simple Queue Service (Amazon SQS) queue. Configure the SQS queue as the destination for failed invocations of the thumbnail-generator Lambda function. Configure the image-resizing Lambda function to poll the SQS queue.
Explanation
SQS queue as intermediary: Using an SQS queue decouples photo-resize requests by queuing them. Even if the thumbnail-generator Lambda function times out or fails, requests are not lost. Failure handling: Configuring the thumbnail-generator Lambda function to send failed invocations to the SQS queue ensures messages re-enter the queue for retry, guaranteeing eventual processing of all photo requests. Image-resizing Lambda function: Configuring it to poll the SQS queue enables it to retrieve and process resize requests reliably without data loss or dropped requests. Why other options are inferior: Option A does not directly resolve timeout issues and lacks explicit queuing or failure-recovery mechanisms. Option C introduces unnecessary complexity; Step Functions is overkill for simple queue-based retry logic. Option D uses SNS, which lacks queuing semantics and is unsuitable for reliable failure recovery. Thus, Option B best satisfies the requirements with minimal development effort and robust failure recovery.