AWS recently announced support for authoring CloudFormation templates in YAML instead of JSON. This is a big deal for one simple reason: YAML supports the use of comments, which has been a major gap in JSON templating.
YAML is a ubiquitous data serialization language and is used a lot for configuration file syntax as well as an alternative to JSON and XML. It has a smallish learning curve because of non-intuitive features like the syntactical importance of indentation. Nevertheless, it offers a strong alternative to authoring files in JSON because of its readability and relative lack of delimiter collision.
If you have existing JSON CloudFormation templates, you can convert them to YAML via the most excellent Python package “json2yaml“. Installing the package is as simple as:
pip install json2yaml
Once installed, you can try converting a template as follows:
cd /path/to/templates json2yaml ./mytemplate.json ./mytemplate.yml
If you do not specify the 2nd parameter for the YAML output file, json2yaml will stream the converted file content to STDOUT.
I used json2yaml to convert a relatively sophisticated JSON-based CloudFormation template for deploying a CodeCommit repository and then used the YAML output version to create a new CF stack and it worked flawlessly.
To learn more about YAML, I recommend reading the Wikipedia page about it along with using this handy reference sheet from yaml.org.
Now, go forth and create stacks with all the comments you have ever wanted to include!