I am trying to validate an AWS example CloudFormation template using a command like:
▶ aws cloudformation validate-template --template-body template.yml
This leads to the following error message:
An error occurred (ValidationError) when calling the ValidateTemplate operation: Template format error: unsupported structure.
I tried this on many templates, including example templates from the AWS documentation. So I know the templates are okay.
What am I doing wrong?
“The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [ApiGatewayRestApi] in the Resources block of the template” When you define a resource in your serverless.yml, you can reference an attribute of another resource dynamically. This error happens when the referenced resource cannot be found.
The template format version can change independently of the API and WSDL versions. The value for the template format version declaration must be a literal string. You can't use a parameter or function to specify the template format version. If you don't specify a value, AWS CloudFormation assumes the latest template format version.
When you create or update an AWS CloudFormation stack, your stack can fail due to invalid input parameters, unsupported resource property names, or unsupported resource property values. For input parameters, verify that the resource exists.
However, to run the AWS Command Line Interface commands, make sure to have the most recent version of the AWS CLI. In case of, “JSON not well-formed” or “YAML not well-formed” errors we can use this step. In order to follow proper JSON or YAML syntax in the CloudFormation template: Initially, we create the stack with AWS CloudFormation Designer.
Apparently, the very unhelpful error message comes as a result of improper formatting in the CLI command.
The --template-body
argument must be specified as a file URI.
Thus, the correct, runnable form of the command above is:
▶ aws cloudformation validate-template --template-body file://template.yml
See this blog post for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With