How to Configure API Gateway Stage-Specific Third-Party Endpoints?

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?

  1. Store the third-party service endpoints in Lambda layers that correspond to the stage.
  2. Store the third-party service endpoints in API Gateway stage variables that correspond to the stage. Source Reference Answer
  3. Encode the third-party service endpoints as query parameters in the API Gateway request URL.
  4. Store the third-party service endpoint for each environment in AWS AppConfig.

Community Votes

B
100%

100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

This question tests your knowledge of API Gateway stage variables as the native, purpose-built mechanism for injecting stage-specific configuration into integration requests.

Amazon API Gateway stage variables allow you to store environment-specific configuration such as third-party service endpoints, enabling a single Lambda function to route to different backends per deployment stage.

Candidates often choose AWS AppConfig (D) because it is a valid AWS configuration service, but it introduces unnecessary complexity and is not the native API Gateway feature designed for per-stage endpoint mapping.

Community Discussion (4 comments)

65703c1 👍 2 Selected: B
B is the correct answer.
KarBiswa 👍 3 Selected: B
https://docs.aws.amazon.com/apigateway/latest/developerguide/amazon-api-gateway-using-stage-variables.html
ANDRES715 👍 2 Selected: B
You.com y chatGpt
CrescentShared 👍 1 Selected: B
D: additional complex C: this is typically used to send data to the end point. Not to configure the endpoint itself. Less secure.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why Option B is Correct

Amazon API Gateway stage variables are key-value pairs that are scoped to a specific deployment stage (dev, UAT, prod). You can reference them in integration URIs, header mappings, and query strings using the syntax $stageVariables.variableName. This makes them the native, simplest, and most cost-effective way to point each stage to a different third-party endpoint without changing Lambda code or adding extra services.

Why the Other Options Are Wrong

  • Option A – Lambda layers: Lambda layers are meant for sharing libraries, dependencies, or custom runtimes, not for storing runtime configuration that changes per stage. A layer is tied to a Lambda function version, not an API Gateway stage.
  • Option C – Query parameters: Encoding endpoints as query parameters exposes internal infrastructure details in the URL, is less secure, and conflates client-supplied data with server-side routing configuration.
  • Option D – AWS AppConfig: While AppConfig can store configuration, it requires additional setup (hosted configuration profiles, deployment strategies) and is overkill for simple per-stage endpoint mapping. Stage variables are already built into API Gateway and require zero extra infrastructure.

Community Consensus

The community voted 100% for B. Commenters noted that stage variables are explicitly designed for this use case and linked the official API Gateway documentation confirming the feature. One commenter correctly pointed out that query parameters are for sending data to an endpoint, not for configuring which endpoint to call.

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide