QuestionQ1

Deployment

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.
Explanation

The best-practice approach is multiple API Gateway stages (test and production), a dedicated Lambda function for each environment, and API Gateway stage variables to route traffic to the appropriate Lambda. This provides true environment isolation, cleaner separation of concerns, and better auditability. Single-stage approaches (A, D) mix concerns; a single Lambda with environment variables (B) is less isolated and harder to troubleshoot independently.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!