CloudFormation

CloudFormation is the basis for most Infrastructure as Code (IaC) frameworks on AWS. They all have a unique syntax that compiles into a CloudFormation template applied to AWS. Therefore, it’s essential to understand CloudFormation before we can get into other IaC frameworks.

CloudFormation has a declarative syntax. That means that it just declares the specifications of all the resources required in the AWS cloud. It doesn’t specify how AWS should create those resources, their sequence, or other related aspects. That’s left for the CloudFormation engine to figure out.

This paradigm comes in handy when we have to modify some resources. When doing so, we need to provide a new CloudFormation template to replace the current one. Again, the CloudFormation engine identifies the difference between the present and target setup and takes care of managing any resources as required.

A complete tutorial on CloudFormation is beyond the scope of this course. However, we’ll look at the core concepts and then check a few common glitches and tricks for debugging a failed deployment.

Core syntax

A simple CloudFormation template can be a valid JSON or YAML (YAML is understandably more prevalent) that has three essential parts:

  • The header declares the version for the format.

  • The parameters section lists all the variables used in the template.

  • The resources contain the actual code that lists all the AWS resources and their properties.

Get hands-on with 1400+ tech skills courses.