This post will cover the following content:
- What is AWS CloudFormation?
- Why should you use it?
- How to use it?
Let's get started...
What is AWS CloudFormation?
AWS CloudFormation comes under the AWS M&G category and it helps in provisioning and configuring AWS resources for you.
You just need to create a CloudFormation template to describe what AWS resources you would like to configure along with the properties/settings, and CloudFormation will create them for you as you described.
Why should you use it?
You should use AWS CloudFormation if you are looking to:
Simplify infrastructure management
Instead of creating and managing individual resources in AWS, you can just a CloudFormation stack to easily manage a collection of resources as a single unit in order to save your time and effort.Quickly replicate your infrastructure
You can reuse your CloudFormation template to provision the same resources in multiple regions without spending time in configuring those resources in each region individually.Easily control and track changes to your infrastructure
CloudFormation templates are nothing but text files which helps you to track changes to your infrastructure just like version controlling. You can easily roll back to your previous infrastructure using a version control system with templates.
How to use it?
AWS CloudFormation is a regional service and you can use AWS CloudFormation via the browser console, command line tools, or APIs to create stack and resources.
Below are the steps to get started:
Go to the AWS CloudFormation Console
Click on
Create stack
in the top right cornerSpecify the Template.
A template is a JSON or YAML file that contains configuration information about the AWS resources you want to include in the stack.
There are 3 options available for you to choose:
- Template is ready - If you have your own template file, then choose this option.
- Use a sample template - If you would like to use a sample template file provided by AWS, you should go with this option.
- Create template in Designer - If you are new to AWS CloudFormation, you can use this option to create, view, and modify AWS CloudFormation templates using a drag-and-drop interface.
I am selecting a sample template LAMP Stack
to begin with CloudFormation.
S3 URL: This is the Amazon S3 bucket URL which is the location of your CloudFormation template file
AWS CloudFormation Sample Template LAMP_Single_Instance: Create a LAMP stack using a single EC2 instance and a local MySQL database for storage. This template demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary to deploy the Apache web server, PHP and MySQL at instance launch time. WARNING This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.
This is how our template will look like in AWS CF Designer tool
- Now, Specify stack details
Stack name: mention a stack name of your choice which can include letters (A-Z and a-z), numbers (0-9), and dashes (-).
Parameters : You can use the given parameters to input customer values while creating or updating the stack.
DBName : Database name for your MySQL DB
DBPassword : Password for your MySQL DB
DBRootPassword : Root password for MySQL DB
DBUser : User name for your MySQL DB access
InstanceType : Specify the EC2 instance type which you would like to use for your WebServer
KeyName : Specify an existing EC2 KeyPair to enable SSH access to the instance.
Make sure you have an existing EC2 keypair created in the specified region. If you do not have one, please create it using the EC2 console and specify the newly created keypair here otherwise stack creation will fail.
SSHLocation : The IP address range that can be used to SSH to the EC2 instances (by default, it is 0.0.0.0/0)
- Next, Configure Stack Options
All the given parameters are optional. You can fill them as per your requirements.
Tags : key-value pairs to apply to resources in your stack
Permissions : Specify IAM role name/ARN. By default, CloudFormation uses permissions based on your user credentials.
Stack failure Options : Specify the behavior when stack creation fails
Advanced Options : You can use these options if you would like to define stack policies for designated resources, setup notification, enable stack termination protection, or configure rollback options.
- Now comes, Review step. You can review all the details of your CloudFormation stack and if everything looks great, click
Create stack
at the bottom right corner to initiate stack creation.
PS: At the bottom, there is a Quick-create link
option available for you to use. You can create more stacks with the same basic configuration as the one you just created using this URL.
- Once the stack creation has completed, you should see the CloudFormation stack status as
CREATE_COMPLETE
Resource tab : You should find all the resources created by CF stack under this tab.
Event tab : You can check the CF stack event details under event tab
Outputs : Under this tab, you should see the website URL for your newly created LAMP stack.
Hope you find this information helpful. Thank you.
Top comments (0)