AWS CloudFormation
Learn how AWS CloudFormation defines infrastructure declaratively with stacks, templates, and change sets for repeatable deployments.
AWS CloudFormation is AWS's native declarative infrastructure as code service and turns resource definitions into managed stacks. For DevOps teams, it matters because it helps teams review, version, and reproduce infrastructure instead of building resources manually in the console. Instead of relying on one fragile manual configuration, you can design a repeatable service boundary that stays stable while the workload behind it changes.
CloudFormation: Stack Deployment Flow
On failure CloudFormation automatically rolls back to the last known good state
Core ideas
The main ideas to understand are templates describe resources, parameters, outputs, and dependencies in JSON or YAML; stacks are the deployed instances of those templates and maintain state about what has been created; change sets show what CloudFormation plans to add, modify, or replace before you execute an update; and CloudFormation is tightly integrated with AWS while Terraform may provide broader multi-cloud support and a different workflow style. These details shape architecture decisions, but they also shape day-to-day operations. When a team chooses defaults without understanding how the service behaves under failure, scale, or security review, the platform often becomes harder to debug than the application itself.
| Aspect | CloudFormation | Terraform |
|---|---|---|
| Provider scope | AWS native | Multi-cloud and ecosystem wide |
| State handling | Managed by the stack service | External state file or backend |
| Integration | Deep AWS alignment | Broad provider flexibility |
From an operations perspective, the goal is to make infrastructure changes reviewable and predictable so environment drift becomes an exception instead of the default state. The comparison below highlights the choices that usually matter first. It is often better to start with a simpler design and add sophistication only after metrics, incidents, or delivery requirements prove the change is necessary.
Practical commands
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple S3 bucket
Resources:
AppBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-demo-app-bucket
Practical CLI checks make the service easier to support in real environments. Use the commands below to inspect the current state and confirm that automation matches intent. Before you promote a change, verify change set output, replacement risk, and stack policy expectations before approving production updates. A safe default is small reusable stacks with clear outputs so dependent systems consume interfaces instead of hidden resource names. That discipline makes later troubleshooting, scaling, and security reviews far less painful.
CloudFormation purpose
What is CloudFormation used for?
Change sets
Why would you create a change set before updating a stack?