How to enable canary deployments for API Gateway in AWS SAM?
A developer is deploying a serverless application using AWS SAM. The application consists of an API Gateway endpoint that triggers an AWS Lambda function. The developer wants to enable canary deployments to gradually shift traffic to a new Lambda version. Which SAM resource attribute should the developer configure?
⚠ Common exam trap
Many candidates confuse `ProvisionedConcurrency` or `ReservedConcurrentExecutions` with deployment strategies, but these are performance and scaling controls, not traffic-shifting mechanisms.
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
✓
AutoPublishAlias and DeploymentPreference
`AutoPublishAlias` automatically creates and updates a Lambda alias (e.g., `live`) that points to the latest version of your function, while `DeploymentPreference` enables canary, linear, or all-at-once traffic shifting between the old and new alias versions. Together, they allow gradual traffic migration to a new Lambda version without manual alias management.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ReservedConcurrentExecutions
Why it's wrong here
ReservedConcurrentExecutions is a Lambda function setting that explicitly limits the maximum number of concurrent invocations for that specific function. Its primary purpose is to prevent a single function from consuming the entire account's concurrency limit, thereby ensuring resource availability for other functions. However, this parameter is solely for capacity reservation and does not provide any mechanism for traffic shifting or phased deployments between different function versions.
- ✗
Timeout
Why it's wrong here
The Timeout setting for an AWS Lambda function defines the maximum duration, in seconds, that a function is allowed to execute before AWS Lambda forcibly terminates its process. This parameter is crucial for preventing runaway functions, managing execution costs, and ensuring responsiveness. While vital for function stability and cost control, the Timeout setting has no direct or indirect role in controlling how traffic is routed or shifted between different versions of a Lambda function during a deployment.
- ✓
AutoPublishAlias and DeploymentPreference
Why this is correct
When deploying serverless applications using AWS SAM or CloudFormation, `AutoPublishAlias` automatically creates or updates an alias to point to the newly deployed Lambda function version. Coupled with `DeploymentPreference`, which integrates with AWS CodeDeploy, this configuration enables sophisticated traffic shifting strategies such as linear or canary deployments. This allows for gradual routing of traffic to the new function version, enabling real-time monitoring for health and performance, and facilitating automated rollbacks if issues are detected, directly addressing the need for controlled traffic shifting.
- ✗
ProvisionedConcurrency
Why it's wrong here
ProvisionedConcurrency pre-initializes a specified number of execution environments for a Lambda function, ensuring that a defined capacity of instances is always warm and ready to process invocations. Its main objective is to significantly reduce cold start times for latency-sensitive applications by eliminating the need for environment setup on demand. While critical for performance optimization, ProvisionedConcurrency is a capacity management feature and offers no functionality for managing or shifting traffic between different versions of a Lambda function during a deployment process.
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 →
Same concept, more angles
1 more way this is tested on DVA-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A developer is deploying a serverless application using AWS SAM. The application consists of an API Gateway REST API and multiple AWS Lambda functions. The developer wants to deploy the application to a production environment with minimal downtime. Which deployment strategy should the developer use?
easy- A.Create a blue/green deployment using AWS Elastic Beanstalk.
- B.Delete the existing stack and deploy a new one.
- C.Perform a rolling update by updating functions one by one.
- ✓ D.Use SAM's built-in canary deployment with traffic shifting.
Why D: AWS SAM supports built-in canary deployments with traffic shifting, which gradually routes a percentage of traffic to the new version while monitoring CloudWatch alarms. This minimizes downtime and allows automatic rollback if errors occur. It is the recommended strategy for serverless applications on API Gateway and Lambda.
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.