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?
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.
The SAM template supports gradual deployments through the 'AutoPublishAlias' property combined with 'DeploymentPreference'. This allows you to specify a canary deployment (or linear) and define CloudWatch alarms for automatic rollback. Option A is incorrect because manually managing 'AWS::Lambda::Version' and 'AWS::Lambda::Alias' does not provide automated rollback. Option B is incorrect because while 'DeploymentPreference' with 'Type: Linear' does enable gradual deployment, the question specifically asks for the SAM-native approach using 'AutoPublishAlias' and 'DeploymentPreference' together; also the 'Alarms' list is specified within 'DeploymentPreference'. Option D is incorrect because 'CodeDeployLambdaAlias' is not a valid SAM resource; SAM abstracts CodeDeploy configuration through the 'DeploymentPreference' property on the Lambda function resource.
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 724-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 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.