Serverless Framework "The CloudFormation template is invalid" in CI
Serverless Framework synthesizes a CloudFormation template from serverless.yml and CloudFormation rejected it at validation. The message names the invalid part: an unresolved reference, an unknown property, or a malformed resource.
What this error means
serverless deploy fails with "Serverless Error ... The CloudFormation template is invalid" plus a ValidationError detail like "Template format error" or "Unresolved resource dependencies".
Error:
The CloudFormation template is invalid: Template error: instance of Fn::GetAtt
references undefined resource MyQueueCommon causes
A reference to a resource that does not exist
A Ref/Fn::GetAtt in resources: or a function event points at a logical id that is not defined, so validation fails.
An invalid property or type in serverless.yml
A misspelled property, wrong type, or unsupported value produces a template CloudFormation cannot parse.
How to fix it
Read the validation detail and fix the reference
- Read the named undefined resource or invalid property.
- Define the missing logical id or correct the property.
- Re-package locally to confirm a valid template before deploy.
serverless package
# inspect .serverless/cloudformation-template-update-stack.jsonPrint and inspect the generated template
Use the print command to see the resolved config that produced the template.
serverless printHow to prevent it
- Package locally before deploying to catch template errors early.
- Reference only logical ids you actually define.
- Validate property names against the resource schema.