Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudformation template validate

According the aws validate-template, I did the test to validate same template from URL and local file.

But I got different output.

Test from URL directly:

$ aws cloudformation validate-template --template-url https://s3.amazonaws.com/cloudformation-templates-us-east-1/S3_Bucket.template
{
    "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.",
    "Parameters": []
}

But when I download it to local, and test again.

$ wget https://s3.amazonaws.com/cloudformation-templates-us-east-1/S3_Bucket.template

2014-12-16 14:48:27 (11.1 MB/s) - 'S3_Bucket.template' saved [652/652]

$ aws cloudformation validate-template --template-body S3_Bucket.template

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

Any idea?

like image 865
BMW Avatar asked Dec 16 '14 03:12

BMW


People also ask

How do I validate AWS CloudFormation template?

If it isn't, CloudFormation checks if the template is valid YAML. If both checks fail, CloudFormation returns a template validation error. You can validate templates locally by using the --template-body parameter, or remotely with the --template-url parameter.

How do you test AWS CloudFormation?

Create CloudWatch events to trigger AWS CodePipeline. Setup CodePipeline and CodeBuild to run TaskCat and testing scripts. Configure TaskCat to deploy CloudFormation solutions in various AWS Regions. Write test scripts to interact with CloudFormation solutions' deployed environments.

Is it possible to test CF templates before creating any resources with them?

Validate templates before using them Before you use a template to create or update a stack, you can use CloudFormation to validate it. Validating a template can help you catch syntax and some semantic errors, such as circular dependencies, before CloudFormation creates any resources.

What is TaskCat?

TaskCat is an open-source tool that is used for testing Amazon Web Services (AWS) CloudFormation templates. It was originally developed by the AWS Quick Start team, which works with AWS Partner Network (APN) Partners to publish AWS CloudFormation reference architectures.


1 Answers

I knew how to fix it now. You need give the file full path with file:///

aws cloudformation validate-template --template-body file:///home/local/test/S3_Bucket.template

Or with relative path ( file:// instead of file:/// ):

aws cloudformation validate-template --template-body file://S3_Bucket.template
like image 156
BMW Avatar answered Nov 03 '22 19:11

BMW