Solve - Template Format Error - unsupported structure


Borislav Hadzhiev

Last updated: Sep 14, 2021


Check out my new book

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 ran 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 #

Use the search field on my Home Page to filter through my more than 3,000 articles.