AWS Cloudformation with YAML

1 minute read

June 2017


YAML Ain’t Markup Language (YAML) was added to AWS cloudformation in September last year for provisioning resources through code via cloudformation.

I definitely find YAML easier to work with and understand than JSON, so going forward will write future cloudformation templates in YAML.

Here’s a comparison of the code for parameters in JSON and YAML:



Not only is YAML clearer to understand (in my opinion), it also allows code comments and has the standard AWS functions such as replacing values with parameters. Below I will demonstrate the code to provision a VM instance in AWS using JSON then YAML with cloudformation.

Here is the complete code to provision an EC2 instance in AWS in an existing VPC and subnet, made reusable with parameters (this template will work for the free tier, check out the details)

Wrap up

Coming from Azure, I used JSON for ARM templates a lot and found the best way to work with them was to install the Azure Resource Manager tools for Visual studio. I find working with YAML much easier to understand and quicker to use, plus I can use my favourite code editor, Visual Studio code to get things done without the need for starting up Visual Studio.