How to Canary-Test Optimized Lambda Code Through API Gateway?
A developer is optimizing an AWS Lambda function and wants to test the changes in production on a small percentage of all traffic. The Lambda function serves requests to a RE ST API in Amazon API Gateway. The developer needs to deploy their changes and perform a test in production without changing the API Gateway URL. Which solution will meet these requirements?
Community Insight
The question tests combining a pinned Lambda version with an API Gateway canary deployment; the trap is choosing a Lambda alias on $LATEST, which is not allowed and cannot provide a stable production baseline.
This DVA-C02 scenario tests AWS Lambda versioning with an API Gateway REST API canary release so optimized code reaches only a small slice of production traffic without changing the URL. The page establishes that option A is correct and that an alias cannot be defined on $LATEST.
Many candidates pick C because a Lambda alias sounds like the idiomatic API Gateway integration target, but aliases cannot point to $LATEST, and directing the canary at $LATEST without a pinned production version blurs stable and test traffic.
Community Discussion (10 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Option A keeps the currently deployed production Lambda behavior on a published version, so the API Gateway REST API can retain the same URL while most production traffic stays on that stable version. The optimized code is uploaded and published, then a canary release on the production API Gateway stage routes a controlled percentage of traffic to the canary configuration that references $LATEST. This satisfies the requirement to test in production on a small percentage of all traffic and allows quick rollback by disabling the canary. It also avoids creating a new API Gateway stage URL, which is central to the question.Why the Other Options Are Wrong
Option B deploys a new API Gateway stage rather than using a canary release on the existing production stage, so it does not provide the required traffic split and changes the invocation URL. Option C is invalid because AWS Lambda aliases cannot point to $LATEST; an alias must target a published version, and simply sending the canary to $LATEST does not preserve a stable production baseline. Option D deploys the API to the production stage without any canary traffic percentage, so all production traffic can hit the changed code instead of only a small test slice. None of these alternatives match the pinned-version plus API Gateway canary workflow described by option A.Community Comment Notes
Some commenters initially favored option C, including KarBiswa and 65703c1, while cerepx and Shamalka later explained that pointing the integration at $LATEST makes the canary ineffective for isolating production traffic. Other learners such as 08dc0cf and minamkcy explicitly flagged "Incorrect use of alias on $LATEST", which is the key AWS Lambda limitation in option C. albert_kuo also outlined the practical option A workflow using publish-version and update-integration, matching the pinned Lambda version approach.Official Reference
Exam Strategy
When a stem requires a production test on a fraction of traffic without changing the URL, look for a pinned Lambda version plus an API Gateway canary release on the existing stage. Reject answers that create a new stage URL or point stable production traffic at $LATEST, and remember that Lambda aliases cannot target $LATEST.
Frequently Asked Questions
Why is an alias on $LATEST invalid for the API Gateway canary?
AWS Lambda aliases can only point to published versions, not $LATEST. Without a published production version, the canary cannot keep a stable baseline separate from the optimized code.
Does API Gateway canary release keep the same REST API URL?
Yes. A canary release on an existing API Gateway stage routes a percentage of traffic to canary settings while clients continue using the same stage invoke URL.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →