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?

  1. Define a function version for the currently deployed production Lambda function. Update the API Gateway endpoint to reference the new Lambda function version. Upload and publish the optimized Lambda function code. On the production API Gateway stage, define a canary release and set the percentage of traffic to direct to the canary release. Update the API Gateway endpoint to use the $LATEST version of the Lambda function. Publish the API to the canary stage.
  2. Define a function version for the currently deployed production Lambda function. Update the API Gateway endpoint to reference the new Lambda function version. Upload and publish the optimized Lambda function code. Update the API Gateway endpoint to use the $LATEST version of the Lambda function. Deploy a new API Gateway stage.
  3. Define an alias on the $LATEST version of the Lambda function. Update the API Gateway endpoint to reference the new Lambda function alias. Upload and publish the optimized Lambda function code. On the production API Gateway stage, define a canary release and set the percentage of traffic to direct to the canary release. Update the API Gateway endpoint to use the $LATEST version of the Lambda function. Publish to the canary stage. Source Reference Answer
  4. Define a function version for the currently deployed production Lambda function. Update the API Gateway endpoint to reference the new Lambda function version. Upload and publish the optimized Lambda function code. Update the API Gateway endpoint to use the $LATEST version of the Lambda function. Deploy the API to the production API Gateway stage.

Community Votes

C
69%
A
31%

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)

0bdf3af 👍 1 Selected: A
A. API Gateway Canary deployment by using versions
Shamalka 👍 2 Selected: A
The answer is A. If you read carefully, in option C, the endpoint is going to be printed to the $LATEST version all the time. So caranr would not be in effective
albert_kuo 👍 2 Selected: A
# create Lambda version aws lambda publish-version --function-name myFunction # Update API Gateway aws apigateway update-integration --rest-api-id api-id --resource-id resource-id --http-method GET --patch-operations op=replace,path=/uri,value=arn:aws:lambda:region:account-id:function:myFunction:1 # Canary Deployments { "percentTraffic": 10, "useStageCache": false }
65703c1 👍 2 Selected: C
C is the correct answer.
KarBiswa 👍 3 Selected: C
C looks more perfect
ANDRES715 👍 3 Selected: C
Al definir un alias en la versión $LATEST de la función Lambda, el desarrollador puede referenciar este alias en el punto final de API Gateway. Luego, al cargar y publicar el código de función Lambda optimizado, se asegura de que la API Gateway haga referencia al nuevo alias de la función Lambda. Después, en la etapa de producción de API Gateway, se puede definir una versión canary y establecer el porcentaje de tráfico que se dirigirá a la versión canary. Esto permite probar los cambios en producción en un pequeño porcentaje del tráfico sin cambiar la URL de API Gateway.
CrescentShared 👍 3 Selected: C
A also looks good, C has an alias created and more like a practical way.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

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 →

← Back to DVA-C02 Study Guide