DVA-C02 Deployment Practice Question
A developer is using AWS SAM to deploy a serverless application. The developer wants to enable canary deployments for the Lambda function. Which TWO resources must be configured in the SAM template? (Choose TWO.)
⚠ Common exam trap
It's easy for candidates to think manually defining a Lambda alias with routing configuration (Option E) is sufficient for canary deployments, but SAM requires both `AutoPublishAlias` (to automate version publishing and alias management) and `DeploymentPreference` (to integrate with CodeDeploy for traffic shifting) — the alias resource alone does not trigger CodeDeploy or enable automated canary rollouts.
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
✓
DeploymentPreference property on the AWS::Serverless::Function resource.
Option A is correct because the DeploymentPreference property on the AWS::Serverless::Function resource is what tells SAM to perform a canary (or linear/all-at-once) deployment, specifying the deployment type, the alias, and the CloudWatch alarms that trigger rollback. Option B is correct because AutoPublishAlias is required for SAM to create and publish a Lambda alias (e.g., 'live') that the canary deployment shifts traffic to; without a published alias, DeploymentPreference cannot route weighted traffic between versions. Option C is not required for canary deployments since CodeUri simply specifies the function's code location and is unrelated to traffic shifting. Option D is not required because an event source mapping only connects the function to a stream/queue and has nothing to do with canary traffic routing. Option E is not required because SAM automatically creates the alias and its routing configuration when AutoPublishAlias and DeploymentPreference are set, so the developer does not need to define an alias resource manually.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
DeploymentPreference property on the AWS::Serverless::Function resource.
Why this is correct
The DeploymentPreference property on the AWS::Serverless::Function resource is fundamental for enabling canary deployments with AWS SAM. It integrates directly with AWS CodeDeploy to define the traffic shifting strategy, such as `Canary10Percent5Minutes`, which gradually routes a small percentage of traffic to the new function version. This property also configures automatic rollback mechanisms based on specified CloudWatch alarms, ensuring a safe and controlled deployment process.
- ✓
AutoPublishAlias property on the AWS::Serverless::Function resource.
Why this is correct
The AutoPublishAlias property is essential for facilitating canary deployments by automatically publishing a new Lambda function version and updating its associated alias. When set to `true`, SAM ensures that a new immutable version of the function is created, and an alias (e.g., `Live`) is automatically managed. This alias is then used by AWS CodeDeploy to orchestrate the controlled traffic shifting between the old and new function versions.
- ✗
The function's CodeUri property pointing to the deployment package.
Why it's wrong here
The function's CodeUri property specifies the Amazon S3 location or local path of the Lambda function's deployment package. While absolutely mandatory for defining the function's code and deploying any serverless function via AWS SAM, it solely dictates *what* code is deployed. It does not, however, configure *how* that code is deployed in terms of traffic shifting or advanced deployment strategies like canary releases.
- ✗
An event source mapping for the function.
Why it's wrong here
An event source mapping connects a Lambda function to a specific event source, such as an Amazon SQS queue or a DynamoDB stream, to trigger the function upon new events. Its primary role is to define the invocation mechanism for the function, not to manage the deployment strategy itself. Therefore, it is entirely unrelated to implementing a canary deployment, which focuses on gradual traffic shifting between function versions.
- ✗
The function's alias resource with a routing configuration.
Why it's wrong here
While Lambda aliases are indeed utilized in canary deployments, the `DeploymentPreference` property in AWS SAM automatically creates and manages the necessary alias and its associated routing configuration through AWS CodeDeploy. Manually defining an alias resource with a `RoutingConfiguration` in your SAM template would duplicate or interfere with this automated process. SAM's built-in canary deployment capabilities abstract away the need for explicit alias routing configuration.
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 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.