4

When I upload a CloudFormation template to AWS's Management Console it takes a few minutes for AWS to process the template.

Doing this for say 20 iterations means a significant chunk of time is just waiting for an error message.

Is there anyway to test it prior to uploading it to AWS's Management Console (preferably a bit more than just "is it valid JSON")?

E.g. a tool that ran through:

  1. is it valid JSON?
  2. is the input to each Resource / Parameter correct?
  3. etc...
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
  • 2
    Possible duplicate of [How can I quickly and effectively debug CloudFormation templates?](http://stackoverflow.com/questions/11854772/how-can-i-quickly-and-effectively-debug-cloudformation-templates) – wjordan Jan 28 '17 at 23:32

1 Answers1

5

you can use the aws cli validate-template command

validate-template

aws cloudformation validate-template --template-body file://path/to/template

In my workflow I have this integrated into a pre-commit git hook to perform some automatic validation

cfn-lint

There is now an awslabs project called cfn-lint that integrates with a variety of editors, it does a more extensive linting of templates. It's available from the awslabs on Github

https://github.com/awslabs/cfn-python-lint

This can also be added as a precommit for your cloudformation workflow

georgealton
  • 1,019
  • 10
  • 18