How to Log Every Lambda Invocation to an SQS Queue?
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?
Community Votes
44% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The question requires logging each invocation, meaning success, final failure, and retryable failures must be recorded; Lambda asynchronous destinations only fire on terminal states (success or final failure), so in-code SDK calls are the only way to capture every single invocation attempt.
This question tests the ability to record every AWS Lambda invocation (success, failure, and retryable failure) into an Amazon SQS queue. Community consensus leans toward using the AWS SDK within the function code because Lambda destinations alone cannot capture retryable failures as distinct records.
Many candidates choose option C or D (Lambda destinations) because destinations are the AWS-native, serverless way to route invocation results to SQS. However, destinations do **not** fire on retryable failures, so they miss invocation attempts, violating the 'each invocation' requirement.
Community Discussion (7 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Understanding the Requirement
The key phrase in the question is 'add a record of each Lambda function invocation'. This means every single invocation attempt — whether it succeeds, fails terminally, or is in a retryable failure state — must produce a record in the SQS queue.
Why Option B is Correct
Option B instructs the developer to add code inside the Lambda function that uses the AWS SDK to call the SQS SendMessage API at the end of the function logic. Because this code runs on every execution of the Lambda function (including retries), it guarantees that a message is sent to SQS for each invocation attempt. This is the only approach that satisfies the 'each invocation' requirement.
Why the Other Options Fail
- Option A (Dead-letter queue): A DLQ only receives messages after all retry attempts are exhausted. It does not log successful invocations or intermediate retry attempts.
- Option C (Two destinations + CloudWatch alarm): Lambda asynchronous invocation destinations fire only on terminal states — final success or final failure. They do not fire on retryable failures. Therefore, retry attempts are not logged. The CloudWatch alarm on
DestinationDeliveryFailuresonly catches cases where the destination itself fails to receive the message, not retryable Lambda failures. - Option D (Single destination for success only): This only captures successful invocations, completely missing failures and retries.
Community Insight
As user Arad correctly points out, asynchronous invocations have three potential states: success, failure, and retryable failure. Destinations only cover the first two terminal states. Users italiancloud2025 and YUICH debated between B and C/D, but the strict wording 'each invocation' makes B the only technically complete answer.
Official Reference
Exam Strategy
When a question says 'each invocation' or 'every invocation,' think about whether the proposed solution captures retry attempts as well as terminal states. Lambda destinations and DLQs only handle terminal outcomes; in-code SDK calls are needed to log every single execution attempt.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →