How to Expose Lambda PROD and DEV Aliases Through API Gateway Stages?
Short answer
D 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.
Question
Key Takeaways
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.
Common mistake: 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.
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
- https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-stage-settings.html
- https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html
These links open the official vendor documentation in a new tab.
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.
Community Votes
100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 4 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 4
-
tgv 👍 11 Answered DUse an API Gateway stage variable to configure the Lambda function alias.
-
KarBiswa 👍 3 Answered Dhttps://datanextsolutions.com/blog/managing-in-production-aws-lambda-functions-with-api-gateway/
-
monishvster 👍 4 Answered Dstage variable in API Gateway
-
65703c1 👍 2 Answered DD is the correct answer.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →