DVA-C02 · Question #528
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…
The correct answer is B. Create code that uses the AWS SDK to call the SQS SendMessage operation to add the. Using the AWS SDK within the Lambda function to call SQS SendMessage is the most direct way to record every single invocation, regardless of success or failure.
Question
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?
Options
- AConfigure the SQS queue as a dead-letter queue for the Lambda function.
- BCreate code that uses the AWS SDK to call the SQS SendMessage operation to add the
- CAdd two asynchronous invocation destinations to the Lambda function: one destination for
- DAdd a single asynchronous invocation destination to the Lambda function to capture successful
How the community answered
(28 responses)- A11% (3)
- B86% (24)
- C4% (1)
Why each option
Using the AWS SDK within the Lambda function to call SQS SendMessage is the most direct way to record every single invocation, regardless of success or failure.
A dead-letter queue only receives messages after all retry attempts have been exhausted on failed invocations; it does not record successful invocations.
By embedding an SQS `SendMessage` SDK call inside the Lambda handler, the function explicitly writes an invocation record to the queue every time it runs. This approach captures 100% of invocations because the message is sent as part of the function's own execution logic, before any return or error path.
Asynchronous invocation destinations configured for both success and failure can capture all outcomes, but because the Lambda is triggered by SNS (asynchronous), configuring two separate destination queues would split records across queues rather than sending all records to one SQS queue.
A single asynchronous invocation destination configured for only one outcome (success or failure) would miss the other outcome, failing to record every invocation.
Concept tested: Recording all Lambda invocations using SDK-based SQS messaging
Source: https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html
Community Discussion
No community discussion yet for this question.