AWS CloudFormation Templates
By the end of this lesson, you'll be able to:
- Explain what AWS CloudFormation is and the template-to-stack relationship
- Read a simple CloudFormation template written in YAML, including its Resources section
- Distinguish a CloudFormation template (a definition) from a stack (the deployed, managed resources)
Prerequisites: "What Is Infrastructure as Code?"
CloudFormation: AWS-native Infrastructure as Code
AWS CloudFormation is AWS's own Infrastructure as Code service. A CloudFormation template is a file — commonly written in YAML — that describes the AWS resources that should exist. Submitting a template to CloudFormation creates a stack: the deployed, managed collection of actual AWS resources described by that template.
A minimal, safe example template
Here is a deliberately minimal, fictional training example:
AWSTemplateFormatVersion: '2010-09-09'
Description: QuarryDev training example
Resources:
TrainingBucket:
Type: AWS::S3::Bucket
Reading this: AWSTemplateFormatVersion identifies the template-format syntax being used (this is a fixed value tied to CloudFormation's template format itself, not a claim about current AWS product versioning). Description is a human-readable label. Resources is where the actual infrastructure is defined — here, one fictional S3 bucket named TrainingBucket, of type AWS::S3::Bucket.
A brief note on reading the YAML itself: indentation indicates nesting (everything under Resources, indented further, belongs to it), and Key: Value pairs describe properties — that's enough YAML to follow every example in this module, without needing to learn YAML as its own subject.
Resources: the only section a template strictly needs
A template can include other sections — Parameters and Outputs, covered in depth next lesson, and Mappings/Conditions for more advanced scenarios this module doesn't need — but Resources is the one section every useful template needs, since it's what actually defines the infrastructure.
Exercise
A colleague says "we already have a CloudFormation template, so our infrastructure is already deployed." Using this lesson's template-versus-stack distinction, explain what's imprecise about that statement, and what step actually has to happen for the infrastructure described by a template to exist as real AWS resources.
Show hint
A template describes what should exist — something still has to happen for that description to become a stack of real resources.
AWS CloudFormation Templates Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
AWS CloudFormation is AWS's native Infrastructure as Code service: a template — commonly written in YAML — defines the AWS resources that should exist, and submitting that template to CloudFormation creates a stack, a deployed and managed collection of the actual resources described by it; the template is the definition, and the stack is what results from deploying it.