AWS CloudFormation Concepts

When you use AWS CloudFormation, you work with templates and
stacks. You create templates to describe your AWS resources and their
properties. Whenever you create a stack, AWS CloudFormation provisions the resources that are described in
your template.

Templates

An AWS CloudFormation template is a text file whose format complies with the JSON standard. You can
save these files with any extension, such as .json,
.template, or .txt. AWS CloudFormation uses these templates as
blueprints for building your AWS resources. For example, in a template, you can describe an
Amazon EC2 instance, such as the instance type, the AMI ID, block device mappings, and its Amazon EC2
key pair name. Whenever you create a stack, you also specify a template that AWS CloudFormation uses to
create whatever you described in the template.

For example, if you created a stack with the following template, AWS CloudFormation provisions an
instance with an ami-2f726546 AMI ID, t1.micro instance type,
testkey key pair name, and an Amazon EBS
volume.

You can also specify multiple resources in a single template and configure these resources
to work together. For example, you can modify the previous template to include an Elastic IP
(EIP) and associate it with the Amazon EC2 instance, as shown in the following
example:

The previous templates are centered around a single Amazon EC2 instance; however, AWS CloudFormation
templates have additional capabilities that you can use to build complex sets of resources and
reuse those templates in multiple contexts. For example, you can add input parameters whose
values are specified when you create an AWS CloudFormation stack. In other words, you can specify a value
like the instance type when you create a stack instead of when you create the template, making
the template easier to reuse in different situations.

For more information about template creation and capabilities, see Template Anatomy.

Stacks

When you use AWS CloudFormation, you manage related resources as a single unit called a stack. In other
words, you create, update, and delete a collection of resources by creating, updating, and
deleting stacks. All the resources in a stack are defined by the stack's AWS CloudFormation template.
Suppose you created a template that includes an Auto Scaling group, Elastic Load Balancing load balancer, and an Amazon RDS
database instance. To create those resources, you create a stack by submitting the template
that you created, and AWS CloudFormation provisions all those resources for you. To update resources, you
first modify the original stack template and then update your stack by submitting the modified
template. You can work with stacks by using the AWS CloudFormation console, API, or AWS
CLI.