You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
AWS CloudFormation is a fully managed Infrastructure as Code service that lets you model, provision, and manage AWS resources by writing templates in JSON or YAML. You describe what you want, and CloudFormation takes care of creating, configuring, and connecting the resources in the right order.
The CloudFormation workflow has three main components:
A template is a text file (JSON or YAML) that describes the AWS resources you want to create. Think of it as a blueprint for your infrastructure. Templates are the input to CloudFormation.
When you submit a template to CloudFormation, it creates a stack — a collection of AWS resources that are managed as a single unit. Every resource in a stack is created from the template, and you manage them together: update them together, monitor them together, and delete them together.
When you need to update a stack, CloudFormation generates a change set that shows you exactly what will change before you apply it. This gives you a chance to review and approve modifications before they take effect.
| Phase | What Happens |
|---|---|
| Create | You submit a template and CloudFormation provisions all the resources |
| Update | You modify the template and submit an update; CloudFormation applies only the changes |
| Delete | You delete the stack and CloudFormation removes all the resources it created |
This lifecycle ensures that your resources are always in sync with your template.
CloudFormation automatically determines the order in which resources must be created. For example, if your template defines a subnet that references a VPC, CloudFormation will create the VPC first and the subnet second. You can also use the DependsOn attribute to specify explicit dependencies.
If any resource fails to create during a stack creation, CloudFormation automatically rolls back the entire stack — deleting any resources that were successfully created. This ensures you never end up with a partially built environment.
Over time, someone might manually change a resource that CloudFormation manages (for example, modifying a security group rule in the console). CloudFormation can detect this drift and report the differences between the expected and actual configuration.
CloudFormation logs every action it takes as a stack event. You can monitor these events in the console, CLI, or through CloudWatch to see the progress of stack operations in real time.
Let's walk through creating a simple stack using the AWS CLI.
Step 1 — Write a template
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.