Introduction
Infrastructure as Code(IaC)
- Infrastructure as code is a declarative way of managing infrastructure such as networks, virtual machines, storage etc.
- IAC also comes with very important principle idempotance. Idempotance ensures it always sets the target environment to same state for the same configuration.
AWS CloudFormation
- AWS CloudFormation is a IaC for the amazon cloud services.
- AWS CloudFormation enables to model your entire infrastructure in a simple text files. To be very specific the CloudFormation uses json or yaml
Basic Workflow of CloudFormation
- Create a CloudFormation Template in Json/YAML .
- Upload it to S3 Bucket
- Create a Stack from the template to provision the infrastructure
Refer here to see how to use the CloudFormation from AWS Console
Terminology
-
Template: Template for the CloudFormation is representation of the infrastructure which has to be provisioned in the JSON/YAML Format.
- Sample JSON Template
{ "Resources" : { "DirectDevopsBucket" : { "Type" : "AWS::S3::Bucket", "Properties" : { "AccessControl" : "PublicRead" } } } }
- Sample YAML Template
Resources: DirectDevOpsBucket: Type: AWS::S3::Bucket Properties: AccessControl: PublicRead
- Sample JSON Template
-
Stacks: All the resources which you manage as a single unit is considered as stack.
If you observer the section with 3 you can observer stack creating multiple resources
-
StackSets:
- StackSets allow you to Deploy AWS Resources in multiple regions using a Single CloudFormation Template.
- Stacksets creates stack in every region you want to create infra.
- If you edit the stackset, then the change will be updated to all the stacks
Setting up your machine for AWS CloudFormation
Please do the following steps
- Install the AWS CLI on your machine by following the links
- Install Visual Studio Code Click here
- Install CloudFormation Extension to Visual Studio
- For general help on installing extensions Click Here
- For info on CloudFormation Extension Click Here
One thought on “AWS CloudFormation Introuction”