DVA-C02 Deployment Practice Question
A developer is deploying a serverless application using the AWS Serverless Application Model (SAM). The developer runs 'sam deploy' and receives an error: 'Error: Failed to create changeset for the stack.' What is a common cause of this error?
⚠ Common exam trap
Test-takers frequently confuse changeset creation failures with permission or bucket issues, but the error message specifically points to template validation, not infrastructure or IAM problems.
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
✓
The SAM template contains a syntax error.
The 'Failed to create changeset for the stack' error typically occurs when the SAM template contains a syntax error, such as invalid YAML formatting, missing required properties, or incorrect resource definitions. AWS CloudFormation validates the template before creating a changeset, and any syntax issue will cause the changeset creation to fail immediately. This is the most common cause because SAM templates are YAML-based and prone to indentation or structural mistakes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The SAM template contains a syntax error.
Why this is correct
When `sam deploy` (or `aws cloudformation deploy`) is executed, the CloudFormation service first validates the template's syntax and structure. If the SAM template, which is an extension of CloudFormation, contains a syntax error (e.g., incorrect YAML/JSON formatting, invalid intrinsic function usage, or malformed resource properties), CloudFormation will fail to parse it. This failure occurs early in the deployment process, specifically preventing the successful creation of a changeset, as the service cannot understand the desired state described by the invalid template.
- ✗
The S3 bucket specified for artifacts does not exist.
Why it's wrong here
The `sam deploy --guided` or `sam package` command first uploads local artifacts (like Lambda function code or layers) to an S3 bucket before creating or updating a CloudFormation stack. If the specified S3 bucket does not exist or the IAM user lacks permissions to write to it, the `sam package` or `sam deploy` command would fail during the *packaging and uploading phase*, typically with an S3-related error message (e.g., "NoSuchBucket" or "AccessDenied"). This occurs *before* CloudFormation even attempts to create a changeset, as the template references S3 locations that haven't been populated yet.
- ✗
The IAM user does not have permission to create CloudFormation stacks.
Why it's wrong here
If the IAM user or role executing the `sam deploy` command lacks the necessary permissions to interact with CloudFormation (e.g., `cloudformation:CreateStack`, `cloudformation:UpdateStack`, `cloudformation:CreateChangeSet`), the operation would be immediately rejected by the AWS API. This rejection typically manifests as an `AccessDeniedException` or similar permission error. This security check happens at the API call level, *prior* to CloudFormation attempting any complex operations like parsing a template or creating a changeset, as the principal isn't authorized to initiate the action at all.
- ✗
AWS CodeDeploy is not configured for the application.
Why it's wrong here
AWS CodeDeploy is an optional service used for advanced deployment strategies, such as blue/green deployments or canary releases, particularly for Lambda functions. While SAM templates can integrate with CodeDeploy for these specific scenarios, it is not a mandatory component for a basic serverless application deployment. If CodeDeploy is not configured or referenced in the SAM template, the deployment will proceed without it, using a standard in-place update. Its absence or misconfiguration would not prevent CloudFormation from creating a changeset unless the template explicitly defined a CodeDeploy resource with errors.
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.