Solve - Template Format Error - unsupported structure


Borislav Hadzhiev

Tue Sep 14 20212 min read

Solving AWS CLI Template Format Error #

The "Template format error: unsupported structure" occurs when we try to run the cloudformation validate-template command without adding the file:// prefix to the --template-body parameter.

Running the command without the file:// prefix throws the error:

aws cloudformation validate-template --template-body cloudformation.yml

template format error

To solve the "Template format error: unsupported structure", we have to prefix the local cloudformation template with file://:

aws cloudformation validate-template --template-body file://cloudformation.yml

with file prefix

When passing local files to AWS CLI parameters we have use the file:// prefix.

In the code snippet I've executed the validate-template command with my terminal open in the directory where the cloudformation.yml file is located.

The local path you pass after the file:// prefix varies between operating systems. For example, on linux and macOS the paths are as follows:

# relative paths aws cloudformation validate-template --template-body file://cloudformation.yml aws cloudformation validate-template --template-body file://./my-directory/cloudformation.yml # absolute path aws cloudformation validate-template --template-body file:///home/john/my-directory/cloudformation.yml
When passing absolute paths on linux or macOS we have three / characters after file:. The first two forward slashes are a part of the file URI scheme and the third slash is a part of the absolute file path.

On windows the path for local files looks like:

aws cloudformation validate-template --template-body file://C:\my-directory\cloudformation.yml

Further Reading #

Add me on LinkedIn

I'm a Web Developer with TypeScript, React.js, Node.js and AWS experience.

Let's connect on LinkedIn

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee