How to Canary-Test Optimized Lambda Code Through API Gateway?

Automate deployment testing. Develop code for AWS Lambda.
Answer Correct answer: A — Pin production to a published Lambda version, then use an API Gateway canary release to send a traffic percentage to $LATEST code without changing REST URL.

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. Correct Answer
  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.
  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 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)

cerepx 👍 2 Selected: A
The trap in this question is C — it looks nearly identical, and "alias" feels like the more idiomatic Lambda construct. Why C is wrong: it defines the alias on $LATEST before the code update, then tries to reference that alias from the API Gateway integration. But $LATEST is mutable — pointing production traffic at an alias tracking $LATEST means both the "stable" and "canary" paths would drift onto the same changing code the moment you upload anything. Freezing a numbered version first is what makes the split actually mean something.
minamkcy 👍 1 Selected: A
Incorrect use of alias on $LATEST
08dc0cf 👍 2 Selected: A
Incorrect use of alias on $LATEST
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 👍 3 Selected: C
C is the correct answer.
KarBiswa 👍 4 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

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.

More DVA-C02 FAQ →

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