How to perform a canary release for an AWS Lambda function behind 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 Votes
69% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
This question really tests whether you understand that Lambda aliases (not versions directly) are the correct way to decouple API Gateway integrations from specific Lambda code versions, enabling safe canary deployments.
This question tests the correct procedure for implementing a canary release for an AWS Lambda function integrated with Amazon API Gateway without changing the API endpoint URL. The community is split, but the consensus leans toward using Lambda aliases combined with API Gateway canary releases to safely test new code on a small percentage of production traffic.
Many candidates choose Option A because it correctly describes using function versions and API Gateway canary releases, but it misses the crucial step of using a Lambda alias to allow seamless code updates without changing the API Gateway integration.
Community Discussion (7 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Understanding Lambda Versions vs. Aliases in Canary Deployments
When deploying AWS Lambda functions behind Amazon API Gateway, it is critical to understand the difference between function versions and aliases. A function version is an immutable snapshot of your Lambda code and configuration. An alias, on the other hand, is a mutable pointer to a specific version, and it can be updated to point to a new version without changing the ARN that API Gateway references.
Why Option C is Correct
Option C correctly outlines the process: 1. Define an alias on the $LATEST version of the Lambda function. 2. Update the API Gateway endpoint to reference this alias (not $LATEST or a specific version). 3. Upload and publish the optimized code, which updates $LATEST. 4. Update the alias to point to the new version (implicitly, as part of the canary process). 5. Define a canary release on the production API Gateway stage, directing a percentage of traffic to the new version via the alias.
This approach ensures that the API Gateway URL remains unchanged, and traffic can be gradually shifted to the new code for testing in production.
Why the Other Options are Incorrect
- Option A: While it describes using function versions and API Gateway canary releases, it fails to use a Lambda alias. Without an alias, updating the Lambda code would require changing the API Gateway integration to point to a new version ARN, which violates the requirement of not changing the API Gateway URL.
- Option B: This option suggests deploying a new API Gateway stage, which would result in a different URL, violating the requirement.
- Option D: Similar to Option B, this option does not utilize canary releases properly and does not ensure the API Gateway URL remains unchanged.
Community Insights
The community is split between Options A and C. Some candidates argue for Option A, citing the use of versions and canary releases. However, as noted by several commenters, Option C is more practical because it uses a Lambda alias, which is the recommended way to decouple API Gateway integrations from specific Lambda versions. This allows for seamless updates and true canary deployments without changing the API endpoint URL.
Official Reference
Exam Strategy
When a question involves deploying Lambda functions behind API Gateway without changing the endpoint URL, always look for the option that uses Lambda aliases. Aliases provide the necessary abstraction to update Lambda code without modifying API Gateway integrations.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →