Course menuDVA-C03

Exams / DVA-C03 / Testing and test automation / Question 2

DVA-C03 practice question: Testing and test automation (2 of 3)

Testing and Deployment A free question from our original DVA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.

Last verified against current AWS documentation ·How we write our questions

A partner API in Amazon API Gateway is a REST API with two stages, dev and prod, and one integration definition shared by both.

The backing Lambda function has aliases named dev and prod that point to different versions. Each stage must invoke only its own alias, and the team wants to avoid copies of the API definition.

Which TWO steps are required? (Choose two.)

Choose two answers.

  1. A. Add a resource-based permission on each alias that lets apigateway.amazonaws.com invoke it, using the alias as the qualifier.
  2. B. Create a separate REST API for each stage, each with its own hard-coded alias and deployment in the integration.
  3. C. Point every integration at $LATEST, which needs no permission and no stage-specific setup.
  4. D. Use ${stageVariables.lambdaAlias} as the alias in the function ARN, with lambdaAlias set to dev or prod per stage.
  5. E. Enable X-Ray tracing on the prod stage so that API Gateway can resolve the alias name.
Show the answer and explanation

Answers: A, D

  • A. Right: Correct. Invoking through an alias needs a permission scoped to that alias. When a stage variable supplies the function name, API Gateway does not add this permission for you, and calls fail with a permission error without it. Learn more: Using Lambda aliases in event sources and permissions policies (opens in a new tab)
  • B. Wrong: This can work, but it breaks the requirement to keep one API definition. Every change must then be made in each copy, which the team wants to avoid.
  • C. Wrong: $LATEST is the unpublished, editable version, so both stages would run the same changing code. This removes the per-stage aliases that keep dev and prod on separate versions.
  • D. Right: Correct. A stage variable holds a per-stage value, so one integration definition can call the matching alias. API Gateway substitutes the value at runtime, depending on the stage that receives the request. Learn more: Use stage variables for a REST API in API Gateway (opens in a new tab)
  • E. Wrong: X-Ray tracing records requests for debugging. It does not change which Lambda alias an integration calls, so it is unrelated to alias routing.

Explanation

Stage variables let one REST API definition call a different Lambda function or alias for each stage, but they do not grant permission. Each alias that API Gateway calls needs its own resource-based permission. Copying the API or pointing at $LATEST each breaks one of the stated requirements.

Study

Keep practicing

Answer questions with a score at the end, or practice just this topic with the explanation after each one. No sign-up needed.

Want more on Testing and test automation? The 5 full-length practice sets have 12 more Testing and test automation questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets