Anatomy of a CloudFormation Template
Useful for automated changes and deployments
In a world where changes are best done automatically, it is important to have the right set of tools for this. Automation helps improve your level of operational efficiency exponentially.
There is much debate about the best IaC (Infrastructure as Code) provider. Some of the most popular options are Terraform, Ansible, and CloudFormation. All of them have pros and cons, but some of the underlying themes of all IaC providers include:
- Maintaining Infrastructure in a desired state
- Consistent deployment of resources
- Significantly higher level of scalability and velocity
- Adherence to company policy for resources
If your resources are mostly on AWS, then it makes sense to use CloudFormation. In a nutshell, CloudFormation templates are just JSON (or YAML) files that describe how you want your resources deployed.
So let’s look at the anatomy of a template to better understand how they allow us to have much better control over our cloud infrastructure.
Below, I have laid out a sample template designed to install the CloudWatch Agent on amazon linux. We will talk more about what each section is and does.