SAM "sam deploy" change set failed / waiter error in CI
sam deploy creates a CloudFormation change set, then executes it. A failure at create time (an invalid template or no changes) or at execute time (a resource failure) stops the deploy with a change set or waiter error.
What this error means
sam deploy fails with "Failed to create the changeset" plus a reason, or "Waiter ChangeSetCreateComplete failed" / "Waiter StackUpdateComplete failed: terminal failure" during execution.
Error: Failed to create changeset for the stack: myapp,
Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state:
Status: FAILED. Reason: Template error: resource Function does not have a HandlerCommon causes
An invalid template rejected at change set creation
A template error (a missing required property, a bad reference) makes CloudFormation refuse to create the change set, surfaced through the waiter.
A resource failure while executing the change set
The change set was created but a resource failed during execution, so the stack rolls back and the execute waiter reports a terminal failure.
How to fix it
Read the change set FAILED reason
- Use the waiter reason text to identify the template or resource error.
- Validate the template to catch structural errors early.
- Fix the template/resource and redeploy.
sam validate --lint
sam deploy --no-confirm-changesetDistinguish create vs execute failures
A ChangeSetCreateComplete failure is a template problem; a StackUpdateComplete failure is a runtime resource problem you read from the stack events.
How to prevent it
- Run sam validate --lint in CI before deploy.
- Review change set diffs for risky resource replacements.
- Keep templates and the SAM CLI version aligned.