How to Configure a Staging Environment for AWS Lambda Using Weighted Aliases?

A developer is updating the code for an AWS Lambda function to add new capabilities. The Lambda function has version aliases for production and development environments that run separate versions of the function. The developer needs to configure a staging environment for the Lambda function to handle invocations to both the development version and the production version. Which solution will meet these requirements?

  1. Create a weighted alias that references the production version of the function and the updated version of the function. Source Reference Answer
  2. Add a Network Load Balancer. Add the production version of the function and updated version of the function as targets.
  3. Use AWS CodeDeploy to create a linear traffic shifting deployment
  4. Create a tag for the Lambda function that contains the production version and updated version of the code.

Community Votes

A
83%
C
17%

83% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

This question tests the knowledge of Lambda aliases and weighted routing, specifically how to route traffic to multiple versions of a Lambda function simultaneously without needing external load balancers or deployment pipelines.

To configure a staging environment for an AWS Lambda function that handles invocations to both development and production versions, you must create a weighted alias. This alias routes a percentage of traffic to each specified function version.

Many candidates incorrectly choose AWS CodeDeploy (Option C) because it is commonly associated with traffic shifting. However, CodeDeploy is a deployment automation tool used to shift traffic over time, whereas the question simply asks to configure a staging environment that handles invocations to both versions simultaneously, which is natively achieved via a weighted alias.

Community Discussion (3 comments)

YUICH 👍 1 Selected: C
AWS CodeDeploy allows you to set up linear traffic shifting deployments for AWS Lambda. This enables you to safely shift traffic gradually between the production and staging versions of the Lambda function, handling calls to both environments effectively.
jasonkym 👍 2 Selected: A
"The developer needs to configure a staging environment for the Lambda function to handle invocations to both the development version and the production version." A weighted alias can divert traffic to both version.
Dahlia9524 👍 3 Selected: A
Alias can mix different version

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 AWS Lambda Aliases and Weighted Routing

The correct answer is A: Create a weighted alias that references the production version of the function and the updated version of the function.

An AWS Lambda alias is a named pointer to a specific Lambda function version. One of the most powerful features of Lambda aliases is weighted routing, which allows you to configure the alias to route a percentage of incoming invocations to one version, and the remaining percentage to another version. This is exactly what is needed to create a staging environment that handles invocations to both the development and production versions simultaneously.

As community members have pointed out, an alias can natively mix traffic between different versions, making it the simplest and most direct solution for this requirement.

Why the Other Options are Incorrect

  • Option B (Network Load Balancer): While an Application Load Balancer (ALB) can target Lambda functions, a Network Load Balancer (NLB) cannot. Furthermore, using a load balancer is an overcomplicated, external solution when Lambda aliases natively support weighted traffic splitting.
Option C (AWS CodeDeploy): This is the most common trap. AWS CodeDeploy is used to automate the process of shifting traffic gradually (e.g., Canary or Linear deployments) over a period of time. The question does not ask to automate a deployment or gradually shift traffic; it simply asks to configure a staging environment that handles invocations to both versions*. A weighted alias achieves this static routing requirement instantly.
  • Option D (Tags): Tags in AWS are strictly metadata used for organization, billing, and resource identification. They have absolutely no capability to route traffic or invoke specific versions of a Lambda function.

Official Reference

Exam Strategy

When reading AWS Lambda questions, distinguish carefully between 'routing traffic to multiple versions' (which requires a weighted alias) and 'automating the gradual shift of traffic during a release' (which requires AWS CodeDeploy). Look for keywords like 'handle invocations to both' versus 'gradually shift' or 'deployment'.

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