DVA-C02 · Question #256
A company is creating a REST service using an Amazon API Gateway with AWS Lambda integration. The service must run different versions for testing purposes. What would be the BEST way to accomplish…
The correct answer is D. Deploy the API versions as unique stages with unique endpoints and use stage variables to. API Gateway stages provide isolated deployment environments for different API versions, and stage variables allow the same API configuration to point to different Lambda functions or aliases per stage.
Question
A company is creating a REST service using an Amazon API Gateway with AWS Lambda integration. The service must run different versions for testing purposes. What would be the BEST way to accomplish this?
Options
- AUse an X-Version header to denote which version is being called and pass that header to the
- BCreate an API Gateway Lambda authorizer to route API clients to the correct API version.
- CCreate an API Gateway resource policy to isolate versions and provide context to the Lambda
- DDeploy the API versions as unique stages with unique endpoints and use stage variables to
How the community answered
(15 responses)- B7% (1)
- C7% (1)
- D87% (13)
Why each option
API Gateway stages provide isolated deployment environments for different API versions, and stage variables allow the same API configuration to point to different Lambda functions or aliases per stage.
Using a custom X-Version header requires the Lambda function itself to implement routing logic between versions, adding application complexity and coupling.
Lambda authorizers handle request authentication and authorization; they are not designed to route traffic between different API versions.
API Gateway resource policies control who can access the API (IP-based, account-based); they do not route requests to different Lambda versions.
Deploying each API version as a distinct stage (e.g., /v1, /v2, /test) gives each version its own endpoint URL and configuration. Stage variables act as key-value pairs that can reference different Lambda function aliases or versions per stage, enabling clean isolation between versions without duplicating API resources or requiring custom routing logic.
Concept tested: API Gateway stages and stage variables for version management
Source: https://docs.aws.amazon.com/apigateway/latest/developerguide/stage-variables.html
Community Discussion
No community discussion yet for this question.