DVA-C02 Deployment Practice Question
A developer is deploying a serverless application using AWS SAM. The application includes an API Gateway REST API and a Lambda function. The developer wants to set up a custom domain name for the API in the production stage. Which resource should the developer define in the SAM template to achieve this with minimal effort?
⚠ Common exam trap
A common mix-up: candidates think they must define the low-level AWS::ApiGateway::DomainName resource directly, overlooking that AWS SAM's AWS::Serverless::Api provides a built-in Domain property that automates the entire custom domain setup with minimal code.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
AWS::Serverless::Api
The AWS::Serverless::Api resource in an AWS SAM template provides a high-level abstraction that simplifies the configuration of API Gateway REST APIs, including the ability to set up a custom domain name via the Domain property. This approach requires minimal effort because SAM automatically creates the underlying AWS::ApiGateway::DomainName and AWS::ApiGateway::BasePathMapping resources, handles the TLS certificate association, and manages the stage deployment. Defining a raw AWS::ApiGateway::DomainName would require additional manual configuration for base path mapping and stage integration, making the Serverless::Api the most efficient choice.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
AWS::ApiGateway::DomainName
Why it's wrong here
`AWS::ApiGateway::DomainName` is tempting as it directly defines a custom domain for an API Gateway REST API. However, for a SAM application aiming for minimal effort, this resource alone is insufficient. It defines the domain and certificate but requires a separate `AWS::ApiGateway::BasePathMapping` resource to associate it with a specific API Gateway stage. SAM offers a higher-level `Domain` property within `AWS::Serverless::Api` which encapsulates this configuration, providing a more streamlined approach for serverless deployments. This resource would be correct when configuring a custom domain directly via CloudFormation, outside of SAM's abstractions.
- ✓
AWS::Serverless::Api
Why this is correct
The AWS::Serverless::Api resource in AWS SAM provides a high-level abstraction for defining an Amazon API Gateway REST API, including its custom domain configuration. By utilizing its `Domain` property, developers can specify a custom domain name, a certificate ARN from AWS Certificate Manager (ACM), and base path mappings directly within the SAM template. SAM then automatically provisions the underlying `AWS::ApiGateway::DomainName` and `AWS::ApiGateway::BasePathMapping` CloudFormation resources, simplifying the setup of custom domains for serverless APIs.
- ✗
AWS::ApiGateway::BasePathMapping
Why it's wrong here
`AWS::ApiGateway::BasePathMapping` maps a base path to an existing custom domain name, but it does not create the domain name itself. The question requires setting up the custom domain name from scratch; this resource only configures the mapping after the domain name resource (`AWS::ApiGateway::DomainName`) is already defined. It is tempting because it directly associates an API path with a domain, which is the final step in production, but it omits the prerequisite domain resource.
- ✗
AWS::Route53::RecordSet
Why it's wrong here
An `AWS::Route53::RecordSet` resource is used to create or update DNS records within Amazon Route 53, such as A records or CNAMEs, which map a domain name to an IP address or another domain. While essential for directing traffic from a custom domain to the API Gateway's regional endpoint, this resource solely handles the DNS resolution aspect. It does not configure the custom domain name directly within API Gateway itself, nor does it manage the required SSL/TLS certificate association, making it insufficient for the complete custom domain setup.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
About these practice questions
Courseiva writes every DVA-C02 question from scratch — 724 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.