Use YAML file format for AWS stack templates

12 May 2017
Tags: aws

When making use of AWS CloudFormation there is currently a file size limit of 51200 bytes on stack templates.

On a reasonable size setup you can quickly hit that limit using JSON format, while YAML format will take you a while longer. A quick example of a file size comparison between the two file formats;

stack.yaml - 3.3K
stack.json - 5.6K

If you want to convert from JSON to YAML you can do that with the following python code snippet.

#!/env/bin python

import json
import yaml

with open("stack.json") as fj:
    with open("stack.yaml", "w") as fy:
        yaml.dump(json.load(fj), fy)

Another option is to handle large stack templates is to make use of Transform