AWS Certified Developer – Associate (DVA-C02) — Question 447
A developer has deployed an AWS Lambda function that is subscribed to an Amazon Simple Notification Service (Amazon SNS) topic. The developer must implement a solution to add a record of each Lambda function invocation to an Amazon Simple Queue Service (Amazon SQS) queue.
Which solution will meet this requirement?
Answer options
- A. Configure the SQS queue as a dead-letter queue for the Lambda function.
- B. Create code that uses the AWS SDK to call the SQS SendMessage operation to add the invocation details to the SQS queue. Add the code to the end of the Lambda function.
- C. Add two asynchronous invocation destinations to the Lambda function: one destination for successful invocations and one destination for failed invocations. Configure the SQS queue as the destination for each type. Create an Amazon CloudWatch alarm based on the DestinationDeliveryFailures metric to catch any message that cannot be delivered.
- D. Add a single asynchronous invocation destination to the Lambda function to capture successful invocations. Configure the SQS queue as the destination. Create an Amazon CloudWatch alarm based on the DestinationDeliveryFailures metric to catch any message that cannot be delivered.
Correct answer: C
Explanation
Because Amazon SNS invokes Lambda asynchronously, the developer can leverage Lambda destinations to route execution results. To ensure that every single invocation is recorded, destinations must be configured for both success and failure conditions. Option C achieves this by mapping both asynchronous execution outcomes to the SQS queue, while Option A only captures failures, Option D only captures successes, and Option B introduces unnecessary code complexity and execution overhead.