What is Amazon CloudFormation?
It is basically a service. Given a scenario where we have executable file, we first install the application. Subsequently, a folder is created and certain files of a package are copied. In short, it is a step to be followed with all files to be executed.
The steps include:
1) Creation of a Security Group
2) Creation of a Key Pair File
3) Launch of an EC2 Instance
4) Installation of Apache, MySQL or any other file.
5) Get Code from S3 and deploy in Web Server
6) Creation of Elastic Load Balancer and give the URL.
This scenario happens when creating a development environment. Every time we have new version of application it follows the steps and only then will it provide a ready environment. A point to note is that it won’t be advisable to do it every time since it’s a long process. Amazon Cloud formation provides an offering where we can follow the steps in an orderly fashion which basically involves providing a template in JSON format scripted language that gives steps to configure data.
CloudFormation is an easy way to create a collection of related AWS resources and provision them in an orderly and predictable fashion. It lets user to create a template and deploy a Stack of AWS resources as defined in the template. The template is in JSON format and the stack will use any resource and follow all these as per template. Also, it’s important to note that if any creation fails, stack will roll out everything. It also becomes easy for User to use CloudFormation since Amazon has a lot of ready templates as well as third parties who have their own templates.
CloudFormation applies when creating a development environment. In a scenario where we have 500 testers and want each tester to test on their own, then we initiate the process by creating environment with steps like launching instance, downloading code, setting up database which becomes a long process. It also includes cases where there is a multiple roll out on application. To shorten time and make it simpler, we run template which will automatically take care of it.
The biggest advantage of cloud formation is that it supports a wide range of Amazon resources along with which we can also configure parameters and gain access to the ready-made templates.
Template in Amazon CloudFormation
It consists of 6 main objects:
- Format version
Here, we give the name of template. While creating we need to take inputs like key name, instance type and web server port. This is an optional item. The mandatory step is specifying the resources. The resources will define the services that will be used. It will create a security group with elements like an open port for everyone. Then, we create an Elastic Load Balancer with elements of health threshold, time out, interval and so on regularly. It also involves elements like web server group, launch configuration and probability zones. In addition, if the user requires it to install Apache, My SQL when launching application, that can also be configured.
Got a question for us? Mention them in the comments section and we will get back to you.