CloudFormation is a tool offered by Amazon to create and configure resources in AWS. Almost all resources in AWS can be created using CloudFormation. It allows to create resources over and over gain by using CloudFormation templates. It is a declarative way for building AWS infrastructure.

The Key for CloudFormation is a template file. It can be either JSON or YAML file. This can be created as files and version controlled. This template can be as simple as couple of lines or a massive file or multiple files depends on the service(s) that are getting provisioned.

Just to create an S3 bucket the template file can be as simple as below

Please note, the indentation of elements is the key in this file. The file will not parse correctly if the indentation is not right.

CloudFormation Building Blocks are as follows:

  1. Resources – AWS resources declared in the template – Mandatory
  2. Metadata – To provide some metadata of the template
  3. Parameters – To provide dynamic inputs for the template
  4. Mapping – The static variables for the template
  5. Conditions – List of conditions to perform during resource creation
  6. Transform – Set of transforms
  7. Outputs – References to what has been created
From AWS Learning Portal