AWS CloudFormation takes care of provisioning and configuring those AWS resources for you. It automates the Infrastructure setup on AWS for you. You just need to create a CloudFormation template elisting the resources and their configuration. The template can be written in JSON or YAML Cloud Formation Templates are reusable which a big advantage. Cloud Formation also provides feedback on the status of your resources.
Let us get started by created a very simple template which creates an S3 bucket(Object Storage).
Template name: template1.json
(Find code on github)
Here is the JSON code you need to add:
After creating the template, log in to your AWS Management Console and under Management tools Click on CloudFormation.
Then Click on “Create new Stack”
Choose the template1.json file to upload to Amazon S3
Enter the Stack name
Skip other sections like Tags and Permissions for demo purpose, and click on Next.
Click on Create to Create a new Stack
Now Stack Creation is in Progress as you can see in the Status Field. You can see the details in the below table.
It takes around 2-3 mins to create the stack and Check when it changes to “CREATE_COMPLETE”
When it completes the stack creation, Now you can go to your S3 service check if the bucket is created or not!!
It our case you can see the bucket name which we mentioned i.e “s3bucket”
The whole bucket name is created as “stackname.bucketname-autoId byS3” for making sure it is a unique bucket name.
So this was the very simple example of a CloudFormation Template and how to create CloudFormation Stack of Resources with it.
Let us create an Ec2 machine using the same process:
Create a template: template2.json(Find code on github)
Save the file.
Now using the same process as described before, upload the template in the CloudFormation and enter the stack name and click on create, then check your EC2 console.