AWS Certified Developer – Associate / Question #688 of 557

Question #688

A company is building a serverless backend for a mobile application using Amazon API Gateway and AWS Lambda. The team needs to deploy updates to a fully isolated, instrumented staging environment for validation before promoting changes to production. Which approach meets these requirements?

A

Deploy a single API Gateway stage. Maintain separate Lambda functions for each environment. Require API consumers to include a header specifying the target environment and corresponding Lambda function.

B

Create multiple API Gateway stages. Use a shared Lambda function across environments. Implement conditional logic in the Lambda code using stage-specific environment variables to handle environment differences.

C

Implement multiple API Gateway stages. Deploy dedicated Lambda functions for each environment. Use API Gateway stage variables to dynamically map API integrations to the appropriate Lambda function version per environment.

D

Use one API Gateway stage. Instruct clients to pass an environment identifier in the request body. Modify the Lambda function to execute environment-specific code paths based on the received identifier.

Explanation

Answer C is correct because:
1. Isolation: Multiple API Gateway stages (e.g., staging/production) ensure environment separation.
2. Dedicated Lambda Functions: Each environment uses its own Lambda function, preventing code/configuration conflicts.
3. Stage Variables: Dynamically map API integrations to environment-specific Lambda versions, enabling controlled testing without affecting production.

Why other options are incorrect:
- A: A single API Gateway stage lacks isolation. Requiring headers for routing introduces client-side complexity and risk.
- B: Shared Lambda functions with conditional logic risk cross-environment interference and violate isolation principles.
- D: A single stage and environment-specific code paths in Lambda expose production to staging bugs, breaking isolation.

Key Points:
- Use API Gateway stages for environment separation.
- Dedicated Lambda functions per environment ensure resource isolation.
- Stage variables enable dynamic routing without code changes.

Answer

The correct answer is: C