Skip to Content

Amazon AWS DVA-C02: Isolating Test and Production Environments with API Gateway Stages

Discover how to create a dedicated, monitored test environment for your Amazon API Gateway and AWS Lambda-based application by leveraging multiple API Gateway stages and configuring stage variables to route requests to separate Lambda functions for each environment.

Table of Contents

Question

A company is developing an ecommerce application that uses Amazon API Gateway APIs. The application uses AWS Lambda as a backend. The company needs to test the code in a dedicated, monitored test environment before the company releases the code to the production environment.

Which solution will meet these requirements?

A. Use a single stage in API Gateway. Create a Lambda function for each environment. Configure API clients to send a query parameter that indicates the environment and the specific Lambda function.
B. Use multiple stages in API Gateway. Create a single Lambda function for all environments. Add different code blocks for different environments in the Lambda function based on Lambda environment variables.
C. Use multiple stages in API Gateway. Create a Lambda function for each environment. Configure API Gateway stage variables to route traffic to the Lambda function in different environments.
D. Use a single stage in API Gateway. Configure API clients to send a query parameter that indicates the environment. Add different code blocks for different environments in the Lambda function to match the value of the query parameter.

Answer

C. Use multiple stages in API Gateway. Create a Lambda function for each environment. Configure API Gateway stage variables to route traffic to the Lambda function in different environments.

Explanation

The correct answer is C. Use multiple stages in API Gateway. Create a Lambda function for each environment. Configure API Gateway stage variables to route traffic to the Lambda function in different environments.

This solution meets the requirements by providing a dedicated, monitored test environment separate from the production environment. Here’s how it works:

  1. Create multiple stages in API Gateway, such as “dev,” “test,” and “prod” for development, testing, and production environments, respectively.
  2. Create a separate Lambda function for each environment (e.g., dev-lambda, test-lambda, prod-lambda).
  3. Configure API Gateway stage variables for each stage, mapping them to the respective Lambda function ARNs.
  4. When deploying the API to a specific stage, API Gateway will automatically route the requests to the corresponding Lambda function based on the stage variables.

By using separate stages and Lambda functions for each environment, you can effectively isolate the test environment from the production environment. The stage variables act as routing mechanisms, ensuring that requests sent to the test stage are processed by the test Lambda function, while requests to the production stage are handled by the production Lambda function.

This approach allows for testing and monitoring the code in the dedicated test environment without impacting the production environment. Additionally, it simplifies the deployment process by eliminating the need for complex conditional logic within the Lambda function.

Amazon AWS Certified Developer – Associate DVA-C02 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Amazon AWS Certified Developer – Associate DVA-C02 exam and earn Amazon AWS Certified Developer – Associate DVA-C02 certification.