Cloud & Software Development

AWS CloudFormation

Also known as: CFN, CDK, AWS CDK, IaC, stack, CloudFormation template

CloudFormation is AWS's native infrastructure-as-code (IaC) service.

You write templates (JSON or YAML) describing AWS resources -- EC2 instances, S3 buckets, VPCs, IAM roles -- and CloudFormation creates, updates, and deletes them as a managed stack. It's the AWS-native alternative to Terraform for deploying AWS infrastructure as code.

AWS CloudFormation, explained at three levels

At home

CloudFormation lets you describe your entire AWS infrastructure in a text file and have AWS create it automatically. Instead of clicking through the AWS console to create each resource by hand, you write a template and CloudFormation builds everything in the right order.

At work

Teams use CloudFormation to ensure their AWS infrastructure is consistent, reproducible, and version-controlled. The same template can create identical dev, staging, and production environments -- eliminating 'it works in dev but not in production' infrastructure differences.

Real-world examples

At home

Sophie created a CloudFormation template that provisions her personal website infrastructure: an S3 bucket with static hosting, a CloudFront distribution, an ACM certificate, and Route 53 DNS records. She can recreate the entire setup in any AWS account in 10 minutes.

At work

Thomas's team uses AWS CDK for all their infrastructure. Python CDK code defines VPCs, ECS clusters, RDS databases, and IAM roles. The CDK pipeline deploys to dev on every commit, staging on merge to main, and production on tag -- all with the same code, different parameters.

Common confusions

  • CloudFormation and Terraform do the same thing — Both are infrastructure-as-code tools, but CloudFormation only manages AWS resources. Terraform supports 100+ cloud providers. CloudFormation has deeper AWS integration (change sets, stack policies, drift detection) but Terraform is preferred for multi-cloud or hybrid environments.
  • You must use YAML/JSON to write CloudFormation — AWS CDK allows you to write CloudFormation in TypeScript, Python, Java, C#, or Go. CDK compiles your code to a CloudFormation template. For new projects, CDK is generally preferred over raw YAML/JSON for its type safety and reuse capabilities.

For analysts

CloudFormation stack deployments create auditable, repeatable infrastructure -- which matters for compliance and cost attribution. BAs doing cloud cost analysis can use CloudFormation stack tags to attribute AWS costs to specific projects, teams, or environments.

History & origin

AWS launched CloudFormation in 2011 as one of the earliest infrastructure-as-code services. It predated Terraform by two years and became the dominant way AWS users automated infrastructure at scale. CloudFormation stacks provide lifecycle management -- resources created together are tracked together and can be deleted together. AWS CDK (Cloud Development Kit, 2019) added a programming language layer on top of CloudFormation, allowing Python, TypeScript, and Java to define infrastructure that compiles to CloudFormation templates.