Exams / DVA-C02 / Testing in development environments / Question 2
DVA-C02 practice question: Testing in development environments (2 of 2)
Deployment A free question from our original DVA-C02 practice exam. Try it, then open the answer to see why each option is right or wrong.
A REST API in Amazon API Gateway has a dev stage and a prod stage. The backing Lambda function has aliases named dev and prod. The developer wants each stage to invoke the matching alias while keeping a single integration definition. Which TWO steps are required? (Choose two.)
Choose two answers.
- AA. Create a separate REST API for each environment with its own integration.
- BB. Define a stage variable such as lambdaAlias on each stage and use ${stageVariables.lambdaAlias} as the qualifier in the integration's function ARN.
- CC. Read an environment variable inside the function to choose which alias to run.
- DD. Configure a canary release on the prod stage that sends traffic to the dev alias.
- EE. Add a resource-based permission on each alias that allows API Gateway to invoke it.
Show the answer and explanation
Answers: B, E
- A. Wrong: This duplicates the integration, which the developer wants to avoid.
- B. Right: Correct. API Gateway substitutes the stage's value at run time, so each stage calls its own alias.
- C. Wrong: Code inside a function cannot change which alias was invoked. The choice must be made by the caller.
- D. Wrong: Canary settings split stage traffic between deployments. They do not map stages to aliases.
- E. Right: Correct. When the function name comes from a stage variable, the invoke permissions must be added manually for each alias.
Explanation
Stage variables are name-value pairs attached to a stage. Used in an integration's function ARN, they let one API definition call a different Lambda function or alias per stage. API Gateway cannot add the invoke permissions automatically in this case, so you add a lambda:InvokeFunction permission for each alias.
Study
Keep practising
Answer questions with a score at the end, or practise just this topic with the explanation after each one. No sign-up needed.