Introduction To AWS CloudFormation

Introduction To AWS CloudFormation

With the breadth and depth of services AWS has to offer, it’s likely that you start off with a simple EC2 instance powering a website, and your architecture stack would look something like this:

 

Figure 1A simple WordPress website

 

And later, once you get used to working on AWS, and the website grows, the stack can gradually evolve into something like:

 

Figure 2: The first one on steroids

 

More services are used; the infrastructure can intelligently grow as traffic increases; there’s a CDN in place and; failsafe mechanisms are now provisioned.

 

For a geek, the transformation is brilliant, and the process of orchestrating it enthralling.

 

This involves learning how to set up multiple different services, understand how they talk to each other, make sure that every single component just works. You probably don’t want to do something that involved. You probably want the entire website with all its bells and whistles to work as simply as an EC2 started, with a few clicks of a mouse on a GUI.

 

Enter AWS CloudFormation

 

CloudFormation enables you to create and manage your infrastructure and application stack in a controlled and predictable way.

 

The CloudFormation service consists of:

 

1.   Templates

 

A JSON text file which defines the resources and/or services which you need.  Templates are also the place where dependencies, runtime parameters, and data flow sequences are defined. Once these are specified, the template is submitted to the CloudFormation service. The JSON contains the following fields:

 

  1. Template format version (optional)—A value denoting the version of the current template. This is completely user—defined, and is usually a date value.
  2. Description(optional)—A string describing what the template does.
  3. Parameters(optional)
  4. Resources(required)—A list of AWS services that the stack must include. This must conform to the following pattern

“Resources”:

{

“Logical_Identifier”:

{

“Type”: Type_of_Resource,

“Properties”:

{

}

}

}

Some resources require the resource field to be populated, and some don’t.

 

  1. Outputs (Optional)—When you run the AWS CloudFormation describe command, the stuff specified in this field is what is returned.

 

2.   Stacks

 

A running instance of a Template is called a Stack. Stacks are combinations of services and resources which run concurrently. Once a stack is up and running, services mentioned in the template driving it are launched.

 

So, the next time you require something as complex as “WordPress onto Amazon EC2 instances in an Auto Scaling group with a multi-AZ Amazon RDS database instance for storage,” don’t roll up your sleeves and start furiously typing away, investigate the CloudFormation sample templates page, because, probably “there’s a CloudFormation template for that”. Here it is, on the off chance that you were interested.

 

References:

 

[1]: https://aws.amazon.com/cloudformation/

[2]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/sample-templates-applications-ap-south-1.html

 

Monali Ghosh
No Comments

Post a Comment

Comment
Name
Email
Website