Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aws cloudformation validate-template keeps giving error (Template format error)

I've been stuck with this from yesterday, I run the below command:

aws cloudformation validate-template --template-body test.json

(test.json is my template) and it keeps on giving me the bellow error:

A client error (ValidationError) occurred when calling the ValidateTemplate operation: Template format error: JSON not well-formed. (line 1, column 5).

I even tried to test with the different aws template samples, and it still gives me the same error(with diff clolumn number). Any solution?

like image 377
Mohammad Avatar asked Sep 17 '14 02:09

Mohammad


People also ask

How do I know if my CloudFormation template is valid?

To check your template file for syntax errors, you can use the aws cloudformation validate-template command. The aws cloudformation validate-template command is designed to check only the syntax of your template.

What is the format for AWS CloudFormation template?

You can author AWS CloudFormation templates in JSON or YAML formats. We support all AWS CloudFormation features and functions for both formats, including in AWS CloudFormation Designer.

How does AWS CloudFormation validate a template being used to create a resource?

Validates a specified template. CloudFormation first checks if the template is valid JSON. If it isn't, CloudFormation checks if the template is valid YAML. If both these checks fail, CloudFormation returns a template validation error.

How do you debug a CloudFormation failure?

log or /var/log/cfn-init. log , to help you debug the instance launch. You can retrieve the logs by logging in to your instance, but you must disable rollback on failure or else AWS CloudFormation deletes the instance after your stack fails to create. You can also publish the logs to Amazon CloudWatch.


1 Answers

The template you posted is valid but there's a syntax error in the command and it's not communicating what the problem is. Try this:

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

like image 56
Ben Whaley Avatar answered Sep 20 '22 03:09

Ben Whaley