DVA-C02 Deployment Practice Question
A developer is deploying a serverless application using the AWS Serverless Application Model (SAM). The application consists of several Lambda functions and an API Gateway. The developer wants to enable gradual deployment of Lambda function versions with automatic rollback based on CloudWatch alarms. What should the developer add to the SAM template?
⚠ Common exam trap
DVA-C02 often tests the misconception that you need to manually create Lambda versions and aliases or use CodeDeploy resources directly, when in fact SAM's `AutoPublishAlias` and `DeploymentPreference` properties handle this automatically.
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
✓
Add 'AutoPublishAlias' and 'DeploymentPreference' properties to the Lambda function resource, specifying a canary deployment with a CloudWatch alarm for rollback.
AWS SAM natively supports gradual deployments through the `AutoPublishAlias` and `DeploymentPreference` properties on the `AWS::Serverless::Function` resource. `AutoPublishAlias` automatically creates a new Lambda version and an alias pointing to it whenever the function code changes. `DeploymentPreference` then instructs SAM to use AWS CodeDeploy to shift traffic to the new version according to a specified strategy (e.g., Canary, Linear, AllAtOnce) and to automatically roll back if any specified CloudWatch alarms trigger. This is the standard, declarative way to enable safe deployments in SAM.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use 'AWS::Lambda::Version' and 'AWS::Lambda::Alias' resources to manually shift traffic and set up CloudWatch alarms to revert the alias if needed.
Why it's wrong here
While 'AWS::Lambda::Version' and 'AWS::Lambda::Alias' are the foundational AWS resources for managing Lambda function versions and directing traffic, using them directly in a CloudFormation template requires manual orchestration for gradual deployments and automated rollbacks. This approach necessitates custom logic or external tooling to monitor metrics and trigger alias updates or rollbacks, unlike SAM's 'DeploymentPreference' which automates this complex integration with CodeDeploy and CloudWatch alarms.
- ✗
Add a 'DeploymentPreference' property with 'Type' set to 'Linear' and specify a 'Alarms' list for rollback.
Why it's wrong here
Adding a 'DeploymentPreference' property with 'Type' set to 'Linear' does enable gradual deployment, but the correct SAM approach is to use 'AutoPublishAlias' together with 'DeploymentPreference'. Also, the 'Alarms' list for rollback is part of 'DeploymentPreference', but option B does not mention 'AutoPublishAlias', which is necessary for automatic version publishing.
- ✓
Add 'AutoPublishAlias' and 'DeploymentPreference' properties to the Lambda function resource, specifying a canary deployment with a CloudWatch alarm for rollback.
Why this is correct
This is the correct approach for implementing automated canary deployments with rollback in SAM. The 'AutoPublishAlias' property on an 'AWS::Serverless::Function' resource automatically creates a new Lambda version and updates an alias to point to it, enabling traffic shifting. Coupled with 'DeploymentPreference', SAM integrates with AWS CodeDeploy to manage the gradual traffic shift (e.g., canary) and automatically rolls back to the previous stable version if specified CloudWatch alarms are breached during the deployment.
- ✗
Add a 'CodeDeployLambdaAlias' resource to the template and configure the deployment group with a canary deployment configuration.
Why it's wrong here
The 'CodeDeployLambdaAlias' resource is not a valid construct within the AWS Serverless Application Model (SAM) template specification. SAM streamlines serverless deployments by abstracting the underlying AWS CodeDeploy integration. Instead of defining separate CodeDeploy-specific resources, SAM's 'AWS::Serverless::Function' resource incorporates deployment preferences directly through its properties, simplifying the configuration for gradual rollouts.
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
This DVA-C02 question is part of Courseiva's 1,135-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint
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.