If you are new to AWS, you might be provisioning services using AWS console. But this is not the standard process. Ideally, the infrastructure should be provisioned using JSON/YAMl scripts. Using these scripts make your infrastructure automated, secure and ordered.
Automated, as running these scripts spin up all the resources written as JSON/YAML without provisioning them manually. Secure, as you can create the entire same architecture in minutes in case of accidental deletion. Infrastructure as code reduces efforts and errors while creating large infra. AWS provides two services/methods to provision as code,
  • AWS CloudFormation - Provision infrastructure using json/yaml scripts
  • CDK (Cloud Development kit)- provision infrastructure using your familiar programming language. Currently supported languages are - javascript, typescript, python, java and .NET.
In this article, I will be covering AWS Cloudformation.
AWS Cloudformation is a service that lets you provision aws resources from json/yaml templates. A cloudformation template is the blueprint of your infrastructure. Cloudformation template make api calls to create your infrastructure. The user using template should have required permissions to provision infrastructure.

Sections of CloudFormation templates

There are various sections of cloudformation template.

Sample Template

Refer the following link to get the sample cloudformation template.
Create a stack in CloudFormation to run the template. You can either upload your template from S3 or from your local machine.
Tips for good cloudformation template,