DVA-C02 · Question #269
A company runs a batch processing application by using AWS Lambda functions and Amazon API Gateway APIs with deployment stages for development, user acceptance testing, and production. A development t
The correct answer is B. Store the third-party service endpoints in API Gateway stage variables that correspond to the. API Gateway stage variables are key-value pairs scoped to a deployment stage, making them the native mechanism for supplying environment-specific configuration such as third-party endpoint URLs to Lambda integrations or HTTP integrations.
Question
A company runs a batch processing application by using AWS Lambda functions and Amazon API Gateway APIs with deployment stages for development, user acceptance testing, and production. A development team needs to configure the APIs in the deployment stages to connect to third-party service endpoints. Which solution will meet this requirement?
Options
- AStore the third-party service endpoints in Lambda layers that correspond to the stage.
- BStore the third-party service endpoints in API Gateway stage variables that correspond to the
- CEncode the third-party service endpoints as query parameters in the API Gateway request URL.
- DStore the third-party service endpoint for each environment in AWS AppConfig.
How the community answered
(48 responses)- A13% (6)
- B75% (36)
- C8% (4)
- D4% (2)
Why each option
API Gateway stage variables are key-value pairs scoped to a deployment stage, making them the native mechanism for supplying environment-specific configuration such as third-party endpoint URLs to Lambda integrations or HTTP integrations.
Lambda layers share code and dependencies across functions but are not scoped per API Gateway deployment stage; a layer would need to be updated and re-associated with each function separately to change an endpoint, which is operationally cumbersome.
Stage variables are directly accessible within API Gateway integration URIs and Lambda function invocations via the `stageVariables` context object, allowing each deployment stage (dev, UAT, prod) to reference a different third-party endpoint without any code changes.
Encoding endpoints as query parameters in the request URL exposes configuration in client-visible URLs, is not maintainable, and requires changes to client applications rather than centralizing configuration in the API definition.
AWS AppConfig is a valid configuration management service but introduces additional infrastructure and complexity; stage variables are the purpose-built, lower-overhead native solution for this exact use case within API Gateway.
Concept tested: API Gateway stage variables for environment-specific configuration
Source: https://docs.aws.amazon.com/apigateway/latest/developerguide/stage-variables.html
Community Discussion
No community discussion yet for this question.