49
votes

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?

2
To the close voters... This question obviously is not off-topic for SO. AWS CloudFormation is a tool used by developers for deploying apps in the cloud; e.g. Serverless apps on Amazon; AWS CFN is a declarative DSL with programming features; SF people without programming knowledge could not answer this question and would have no use for it.Alex Harvey

2 Answers

121
votes

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.

0
votes

In case, you are using windows file system, you can use like this:

--template-body file://c:/Windows/myfile.json

or

--template-body file://localhost/c$/Windows/myfile.json