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:
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:
- Template format version (optional)—A value denoting the version of the current template. This is completely user—defined, and is usually a date value.
- Description(optional)—A string describing what the template does.
- Resources(required)—A list of AWS services that the stack must include. This must conform to the following pattern
Some resources require the resource field to be populated, and some don’t.
- Outputs (Optional)—When you run the AWS CloudFormation describe command, the stuff specified in this field is what is returned.
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.