How to Expose Lambda PROD and DEV Aliases Through API Gateway Stages?

A company is using Amazon API Gateway to invoke a new AWS Lambda function. The company has Lambda function versions in its PROD and DEV environments. In each environment, there is a Lambda function alias pointing to the corresponding Lambda function version. API Gateway has one stage that is configured to point at the PROD alias. The company wants to configure API Gateway to enable the PROD and DEV Lambda function versions to be simultaneously and distinctly available. Which solution will meet these requirements?

  1. Enable a Lambda authorizer for the Lambda function alias in API Gateway. Republish PROD and create a new stage for DEV. Create API Gateway stage variables for the PROD and DEV stages. Point each stage variable to the PROD Lambda authorizer to the DEV Lambda authorizer.
  2. Set up a gateway response in API Gateway for the Lambda function alias. Republish PROD and create a new stage for DEV. Create gateway responses in API Gateway for PROD and DEV Lambda aliases.
  3. Use an environment variable for the Lambda function alias in API Gateway. Republish PROD and create a new stage for development. Create API gateway environment variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias to the DEV Lambda function alias.
  4. Use an API Gateway stage variable to configure the Lambda function alias. Republish PROD and create a new stage for development. Create API Gateway stage variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias and to the DEV Lambda function alias. Source Reference Answer

Community Votes

D
100%

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

Community Insight

This question tests whether you know that API Gateway stage variables can dynamically point to different Lambda aliases per stage, avoiding redeployment and enabling multiple environments from the same API definition.

To make PROD and DEV Lambda aliases simultaneously available through Amazon API Gateway, use API Gateway stage variables to parameterize the Lambda function alias. Community consensus strongly favors this approach, with all votes selecting stage variables.

Choosing C because it mentions environment variables; API Gateway does not use environment variables for Lambda function aliases, but stage variables are the correct API Gateway mechanism for per-stage configuration.

Community Discussion (4 comments)

tgv 👍 11 Selected: D
Use an API Gateway stage variable to configure the Lambda function alias.
65703c1 👍 2 Selected: D
D is the correct answer.
KarBiswa 👍 3 Selected: D
https://datanextsolutions.com/blog/managing-in-production-aws-lambda-functions-with-api-gateway/
monishvster 👍 4 Selected: D
stage variable in API Gateway

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 D correctly identifies API Gateway stage variables as the way to configure different Lambda aliases for different stages. By republishing the PROD alias and creating a new DEV stage, you can set a stage variable such as lambdaAlias to PROD in one stage and DEV in the other. The API integration then references the stage variable, e.g., arn:aws:lambda:region:account:function:myFunction:${stageVariables.lambdaAlias}, allowing both aliases to be simultaneously and distinctly available. This approach is clean, supported by AWS, and avoids hardcoding the alias in the integration request.

Why the Other Options Are Wrong

Option A is incorrect because Lambda authorizers are for authentication/authorization, not for routing to different function aliases. Option B is incorrect because gateway responses handle error messages and custom response templates, not Lambda alias selection. Option C is incorrect because API Gateway does not use environment variables for Lambda function aliases; environment variables are a Lambda function feature, not an API Gateway stage feature. Only stage variables provide the per-stage mapping needed for PROD and DEV aliases in API Gateway.

Community Comment Notes

Community comments overwhelmingly support D, with comments like "Use an API Gateway stage variable to configure the Lambda function alias" (11 likes) and "stage variable in API Gateway" (4 likes). One commenter shared a blog post about managing Lambda functions with API Gateway, reinforcing the practical use of stage variables. No comment suggested any other option, confirming D as the consensus answer.

Official Reference

Exam Strategy

When you see a question about API Gateway and Lambda aliases for different environments, immediately think of API Gateway stage variables. Stage variables let you change the Lambda function alias without redeploying the API, and they are the standard solution for making PROD and DEV simultaneously available through separate stages.

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