Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template format error: unsupported structure seen in AWS CloudFormation

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?

like image 776
bgenchel Avatar asked Feb 02 '17 00:02

bgenchel


People also ask

Why is my CloudFormation template invalid?

“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.

How to change the template format version in AWS CloudFormation?

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.

Why did my AWS CloudFormation stack fail?

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.

How to fix “JSON not well-formed” error in AWS CloudFormation?

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.


1 Answers

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.

like image 140
bgenchel Avatar answered Oct 12 '22 19:10

bgenchel