AWS Certified Developer – Associate / Question #798 of 557

Question #798

A company is operating a REST API using Amazon API Gateway integrated with AWS Lambda. They need to simultaneously run two different versions of their API for A/B testing purposes. What is the MOST effective method to implement this?

A

Use a custom query parameter to specify the API version and configure the Lambda function to process requests accordingly.

B

Implement an API Gateway canary release deployment to split traffic between the two versions based on a percentage.

C

Apply an API Gateway resource policy that routes incoming requests to the appropriate version based on the client's IP address.

D

Deploy each API version as a separate stage with distinct endpoints and utilize stage variables to manage environment-specific configurations.

Explanation

Answer D is correct because API Gateway stages provide isolated environments for different API versions. By deploying each version as a separate stage, the company can maintain distinct endpoints (e.g., /v1 and /v2) and use stage variables to manage environment-specific configurations (e.g., Lambda function ARNs). This approach ensures clean separation between versions, simplifies testing, and avoids mixing logic in the Lambda function.

Why other options are incorrect:
- A: Using query parameters shifts routing logic to the Lambda function, complicating code and violating separation of concerns.
- B: Canary deployments split traffic within a single stage but are designed for gradual rollouts, not long-term simultaneous versions.
- C: Resource policies control access (e.g., IP allowlists) but cannot route traffic between API versions.

Key Points:
1. Stages in API Gateway enable isolated deployments with unique endpoints.
2. Stage variables allow dynamic configuration (e.g., Lambda versions).
3. A/B testing requires clear separation, which stages provide.

Answer

The correct answer is: D