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?
Community Votes
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)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
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 →