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.
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.
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:
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.
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
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
Lastly, we will need
Properties under the specific resource.
AWS::EC2::Instanceis telling the cloud formation this is the EC2 Instance
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.
Tutorial - Create an EC2 Instance with below requirements
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.