What is AWS CloudFormation?
In the simplest terms, to manage a complex application’s resources will become a problem for developers. It would be a difficult task to monitor and manage every single resource in the application.
Check this Intellipaat AWS video :
AWS CloudFormation came in to solve this problem and did it seamlessly.
AWS CloudFormation provides a common platform and language which you can use to describe and provision all the AWS infrastructure resources and services in your cloud environment. You can provision and use them in an orderly and predictable manner.
You can describe, provision resources which are secure and also mention regions in a simple text file. AWS Cloudformation is free! Basically, you don’t need to pay for CloudFormation, you only pay for the services and resources which you are running using AWS. You can automate repeated tasks and make your work much easier. Interconnecting multiple resources using CloudFormation is as easy as creating a single EC2 instance.
Get certified from top AWS course in Bangalore Now!
But what is the difference between AWS CloudFormation and Elastic Beanstalk?
Both services are designed to serve one another. Elastic Beanstalk is used to create an environment of any programming platform and easily deploy your applications and run it in the cloud. Developers tools are an add-in in Elastic Beanstalk. Now about CloudFormation, it is a provisioning mechanism which can be used to create a predictable, recursive order to a wide range of services. A complete infrastructure can be created using AWS CloudFormation.
AWS CloudFormation lets you create your template using JSON or YAML-format, which will be a simple text file that describes all the AWS resource to deploy and run your application.
The topics which are discussed in this tutorial are:
How does AWS CloudFormation work?
Let us see the CloudFormation’s working model in a step by step basis.
- You code your infrastructure in a YAML or JSON text-based file which is called a template
- Create your code locally in the AWS CloudFormation tool or upload a YAML or JSON file into the S3 bucket
- You can now either use the GUI of AWS CF or the Command Line Interface to create a stack based on your template code
- Finally, CloudFormation will deploy resources, provision it and configures the template which you specified.
Want to read more about AWS? Go through this AWS Tutorial!
AWS CloudFormation Benefits
CloudFormation provides the user with several benefits and they are:
- It’s just code
- Automation of Infrastructure
- Safety controls
- Model it all
It’s just code
- You can treat your infrastructure as a code which makes it very simple and easy to modify and do changes accordingly.
Automation of Infrastructure
- The developer doesn’t have to care about provisioning resources, he only needs to make his application better. All the provisioning and managing of resources will be taken care of by CloudFormation
If you have any doubts or queries related to AWS, do post on AWS Community.
- There are no manual steps or steps which leads to an error. The controls are automated to reduce effort and increase quality and performance.
- Using AWS Lambda you can create your own extensions and add it to the CloudFormation template. CloudFormation stack provides an extensible mechanism to make this possible. Custom provisioning of extensions can be made for a third party resource.
Model it all
- This is the best part of CloudFormation. You can model an entire AWS Infrastructure in a text file and use that template to build multiple Infrastructures using a single code. Troubleshooting the components available in the infrastructure is very easy because it is contained within one text file.
A stack is a collection of various AWS resources put together as a single unit. You can create, update, or delete a collection of AWS resources by creating, updating, and deleting stacks.
For example, a stack could contain all the resources required to run a web application such as a web server, a database, and networking rules. You can just update the stack and the entire web application will get updated. If you no longer require the application, you can simply delete the stack and all of the resources will get deleted.
Are you preparing for AWS interview? Then here are latest AWS interview questions
AWS CloudFormation only allows stack resources to be created or deleted as appropriate. As the resources are treated as a single unit, they all should be either created or deleted successfully. If a resource cannot be created, then the entire stack is dropped or deleted. If a resource cannot be deleted, other resources are retained until the stack is completely deleted. You can work with stacks by using the AWS CloudFormation console, API, or AWS CLI.
Looking for AWS Training? Join Intellipaat’s AWS Training in Chennai now!
To provision and configure your stack resources, you must first understand the concept of CloudFormation templates. Templates are formatted text files in JSON or YAML. The resources which you want to provision in your CloudFormation stacks are described in these templates. You can use AWS CloudFormation Designer or any text editor to create and save templates. If you are unfamiliar with JSON or YAML, you can use the visual designer provided by AWS.
Now let us take a look at the structure of a template.
There are multiple sections in a Template:
- Format Version (optional)
- The AWS CloudFormation template version identifies the capabilities of the template
- Description (optional)
- Text string describing the template
- Metadata (optional)
- Additional information about the template
- Parameters (optional)
- Values to pass to your template at runtime
- Mappings (optional)
- mapping of keys and associated values that you can use to specify conditional parameter values, similar to a lookup table
- Conditions (optional)
- Additional conditions for creating resources
- Transform (optional)
- The optional Transform section specifies one or more macros that AWS CloudFormation uses to process your template
- Resources (required)
- Specifies the stack resources and their properties, such as an Amazon Elastic Compute Cloud instance or an Amazon Simple Storage Service bucket.
- Outputs (optional)
- Describes the values that are returned whenever you view your stack’s properties
Only the Resources section is mandatory, all the other sections are additional inputs.
JSON file structure:
YAML file structure:
Companies who use AWS CloudFormation
Expedia and Football Club Barcelona are two of the clients who use AWS CloudFormation. Both the companies have their mobile apps and web applications and for the purpose of automation and provisioning, they use CloudFormation.
FC Barcelona is a huge football team with over 100 million fans across the world. As in every sport, there will always be a traffic spike to their sites and pages. CloudFormation helps in making it into a single unit and create, delete and update whenever required. Same goes with Expedia. Expedia is all-in with AWS, and they are planning to bring 80% of mission-critical applications into AWS infrastructure. They are using CloudFormation stacks for every separate application for easy maintenance.
Other companies who use CloudFormation are Nextdoor and coinbase.
If you are using Amazon Web Services for your application then go for CloudFormation so that you can create multiple infrastructures, troubleshoot your components, and also recover your application’s resources whenever there is a failover.
Hope this helps. Keep reading this tutorial to learn more about Amazon Web Services.