AWS CloudFormation 101 -What is CloudFormation and Do I Need to Know About It (Part 1)

Published 2021-06-14


If you're new to AWS, you might feel a little bit overwhelmed at the first moment you come into AWS Cloud Formation. ( My feeling at that moment ). Thus, I decided to learn as minimal as possible and trying to master it.

Turned out, the approach was really working well for me and I believe it would work well on most people as well.

So in the upcoming series of posts, I will share with you about How I Learned about AWS CloudFormation with some bite-sized tutorials.

Without further ado, let's start.

What is CloudFormation?

Cloud Formation is a tools or solutions that enable you to manage AWS resources using a template file.

It's like coding your own AWS infrastructure setup and it can be done within a template.

Why do we need to learn CloudFormation?

Now, we have a basic idea of what is cloud formation. You might be asking "Why do I need to learn about it?" I am glad if you asked this from the beginning.

The truth I would tell you is "You don't really need to". This is because if your company or business are using Elastic Beanstalk - which the Infrastructure setup is automatically managed. Then you don't have to really learn about it.

However, this sounds too good to be true because there's still a lot of companies or business out there love to have the flexibility and full control over their infrastructure.

Thus, if you're required to manage your AWS infrastructure, then it's best to learn about CloudFormation as it provides such benefits:

  • **Simplify your infrastructure management **- as you could probably imagine, your whole infrastructure is managed within a code template.
  • Quick Replication of infrastructure - AWS resources is region-based. So if you would like to have same infrastructure setup for both US - Ohio and Singapore. You will need to provision all the resources again in another region. This come in handy with CloudFormation.

At this point, you already know the reason to learn it and the benefits of using CloudFormation. Next we will go into the first tutorial.

Tutorial 1 - Create an EC2 Instance

In this tutorial, we will be creating a simple EC2 Instance using the Cloud Formation template.

I will be using yaml for the template format. Up until now, you can use either json or yaml format for the CloudFormation template.

There is a standard format in Cloud Formation template. Refer to the below.

Resources: LogicalIDForTheResource: Type: Properties:

We have to define AWS component under Resources. The component could be EC2 Instance, Security Group, Load Balancer, and basically everything in AWS.

Then, we need to define the logical ID for the resource, I would recommend you to give it a proper naming so you could easily identify the purpose of each resource. For e.g, if you create a security group for load balancer, you could named it as LoadBalancerSecurityGroup.

Lastly, we will need Type and Properties under the specific resource.

  • Type - the type of resources. For e.g, AWS::EC2::Instance is telling the cloud formation this is the EC2 Instance
  • Properties - Different between each type of AWS resources and some of them is required to be defined.

You can find all the properties for EC2 Instance here.

Now, you already have the idea fo the Cloud Formation template structure works. Let's do some hand-ons to enhance the learning experience.

Hands-on Time 👨‍💻👩‍💻

Tutorial - Create an EC2 Instance with below requirements

  • Availability zone - ap-southeast-1a
  • Instance type - t2.micro ( Free Tier )
  • ImageId P/S: ImageId is different between each region. You might need to be alert about this.

Lastly, you might want to upload the template file to AWS CloudFormation so you able to see whether your EC2 Instance created successfully.

Try it out and if you're stuck, final answer is available here.


In this post, we learned about what is CloudFormation, Why we should learn about it, and also the benefits Cloud Formation brings to us.

Besides, this post also explains the basic structure of the CloudFormation template and the tutorial allows us to learn about how to provision an EC2 Instance using CloudFormation.