DVA-C02 Question 310
Single answerYou are developing a serverless application using Amazon API Gateway and AWS Lambda. You have deployed multiple stages (e.g., 'dev', 'test', 'prod') in API Gateway. You want to configure a custom domain to route requests to the 'prod' stage while ensuring that the API calls use a user-friendly URL. How can you achieve this?
- A
Create a custom domain name in API Gateway, associate it with the 'prod' stage, and configure a base path mapping.
- B
Create a custom domain name in API Gateway, enable stage variables, and configure the custom domain to point to the 'prod' stage.
- C
Create a custom domain name in API Gateway and configure a DNS record in Route 53 to point to the 'prod' stage's endpoint URL.
- D
Configure a CloudFront distribution with the API Gateway endpoint as the origin, and use Route 53 to map the custom domain to the CloudFront distribution.
Show answer and explanation
Correct answer: A
Explanation
To use a custom domain for a specific API Gateway stage, you must configure the custom domain within API Gateway and associate it with the stage using base path mapping. This ensures that requests to the custom domain are routed to the correct stage. Additionally, DNS settings in Route 53 or another DNS service must be configured to point to the custom domain in API Gateway. While CloudFront can be used in specific cases (e.g., caching or additional functionality), it is not required for this scenario.
- A. Correct.
Correct. To use a custom domain with an API Gateway stage, you need to create a custom domain name in API Gateway, associate the domain with the desired stage using base path mapping, and configure DNS settings in Route 53 or another DNS service.
- B. Incorrect.
Incorrect. Stage variables are used for dynamic runtime configuration within API Gateway, not for associating custom domains with specific stages.
- C. Incorrect.
Incorrect. While creating a DNS record in Route 53 is necessary for the custom domain to resolve, you must still set up the custom domain and base path mapping within API Gateway.
- D. Incorrect.
Incorrect. CloudFront is not required to route traffic to API Gateway stages. API Gateway natively supports custom domains and base path mappings for this purpose.