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
# This name can be anything
# Comment will start with # symbol
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:
- Resources – AWS resources declared in the template – Mandatory
- Metadata – To provide some metadata of the template
- Parameters – To provide dynamic inputs for the template
- Mapping – The static variables for the template
- Conditions – List of conditions to perform during resource creation
- Transform – Set of transforms
- Outputs – References to what has been created