AWS Certified Developer – Associate (DVA-C02) — Question 275
A company is using Amazon API Gateway to invoke a new AWS Lambda function. The company has Lambda function versions in its PROD and DEV environments. In each environment, there is a Lambda function alias pointing to the corresponding Lambda function version. API Gateway has one stage that is configured to point at the PROD alias.
The company wants to configure API Gateway to enable the PROD and DEV Lambda function versions to be simultaneously and distinctly available.
Which solution will meet these requirements?
Answer options
- A. Enable a Lambda authorizer for the Lambda function alias in API Gateway. Republish PROD and create a new stage for DEV. Create API Gateway stage variables for the PROD and DEV stages. Point each stage variable to the PROD Lambda authorizer to the DEV Lambda authorizer.
- B. Set up a gateway response in API Gateway for the Lambda function alias. Republish PROD and create a new stage for DEV. Create gateway responses in API Gateway for PROD and DEV Lambda aliases.
- C. Use an environment variable for the Lambda function alias in API Gateway. Republish PROD and create a new stage for development. Create API gateway environment variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias to the DEV Lambda function alias.
- D. Use an API Gateway stage variable to configure the Lambda function alias. Republish PROD and create a new stage for development. Create API Gateway stage variables for PROD and DEV stages. Point each stage variable to the PROD Lambda function alias and to the DEV Lambda function alias.
Correct answer: D
Explanation
Using API Gateway stage variables allows you to dynamically define which Lambda function alias is invoked based on the stage processing the request (such as PROD or DEV). By creating a new stage for development and configuring stage variables in both the PROD and DEV stages to point to their respective Lambda aliases, you can route traffic to the correct environment concurrently. Other options are incorrect because Lambda authorizers, gateway responses, and "environment variables" (which do not exist in API Gateway) are not designed for routing requests to different Lambda function aliases.