# AWS CloudFormation

> AWS CloudFormation is the native infrastructure as code service of AWS: describe resources in JSON or YAML templates and it manages them as stacks.

- Source: https://www.itwonderlab.com/aws-cloudformation/
- Published: 2026-10-05
- Updated: 2026-10-05
- Author: Javier Ruiz Jiménez (https://www.javierruizjimenez.com/)
- Site: IT Wonder Lab (https://www.itwonderlab.com/)

---

**AWS CloudFormation** is the infrastructure as code ([IaC](https://www.itwonderlab.com/iac/)) service of AWS. You describe the resources in a **template** (JSON or YAML) and CloudFormation creates, updates and deletes them in the right order as a single unit, a **stack**.

### Key concepts

- **Template** with *parameters*, *resources*, *mappings*, *conditions* and *outputs*, and built-in functions such as `!Ref` and `!Sub`.
- **Stack**: the resources created from a template. **Change sets** preview the changes before applying them, and a failed update is **rolled back** automatically.
- **StackSets** deploy stacks to several accounts and Regions; **nested stacks** and **modules** reuse templates.
- **Drift detection** finds resources changed outside of CloudFormation.
- **AWS CDK** and the Serverless Application Model (SAM) generate CloudFormation templates from programming languages.
- **No extra cost**: you pay only for the resources that it creates (third-party resource handlers have a cost).

### CloudFormation or Terraform / OpenTofu?

| | CloudFormation | Terraform / OpenTofu |
|---|---|---|
| Clouds | AWS only | AWS, Azure, Google Cloud, Kubernetes, SaaS and more |
| Language | JSON / YAML (or CDK) | [HCL](https://www.itwonderlab.com/hcl/) |
| State | Managed by AWS | A state file ([backend](https://www.itwonderlab.com/aws-terraform-tutorial-terraform-backends/)) that you manage |
| Support for new AWS features | Usually first | Soon after, through the provider |

Terraform can also manage CloudFormation stacks with the resource `aws_cloudformation_stack`.

See also: [HCL](https://www.itwonderlab.com/hcl/), [Terraform Built-in Functions](https://www.itwonderlab.com/terraform-functions/).
