Question #956
An AWS Lambda function is triggered asynchronously by Amazon S3 whenever a new object is uploaded. Occasionally, the function fails to process some events. The developer needs to collect these failed events for troubleshooting with minimal additional setup.
What should the developer do to meet these requirements with the LEAST development effort?
Enable detailed logging in the Lambda function and analyze Amazon CloudWatch Logs for error messages.
Configure an AWS Step Functions state machine to handle retries and capture failed events.
Assign a dead-letter queue using Amazon SQS to capture failed invocations.
Use an Amazon SNS FIFO topic to route failed events to a logging service.
Explanation
When AWS Lambda is invoked asynchronously (e.g., by S3), failed events are retried twice by default. To capture events that fail after all retries, a dead-letter queue (DLQ) can be assigned to the Lambda function. This requires only configuring an SQS queue in Lambda's settings, with no code changes or additional infrastructure.
Why other options are incorrect:
- A: Logging errors in CloudWatch does not guarantee capturing the actual event data causing failures, requiring manual logging code changes.
- B: Step Functions adds complexity, requiring a state machine setup and workflow changes.
- D: SNS FIFO topics are unnecessary unless strict ordering is required, and routing via SNS involves more setup than SQS.
Key Points:
- Use DLQ (SQS/SNS) for asynchronous Lambda failures.
- Minimal setup: No code changes; configure via Lambda console/CLI.
- DLQ ensures failed events are retained for troubleshooting.
Answer
The correct answer is: C