CloudFormation vs CDK vs Terraform: Which IaC Tool?
CloudFormation is AWS's native engine, CDK writes CloudFormation in real code, and Terraform is a multi-cloud alternative.
All three let you define infrastructure in files instead of clicking in the console. The differences are the language, who tracks state, and which clouds they cover.
Side-by-side
| CloudFormation | AWS CDK | Terraform | |
|---|---|---|---|
| Language | YAML or JSON | TypeScript, Python, Java, C#, Go | HCL (its own config language) |
| Under the hood | AWS's deployment engine | Generates CloudFormation | Calls cloud APIs directly via providers |
| State | Managed by AWS | Managed by AWS (via CloudFormation) | A state file you store and lock (e.g. in S3) |
| Clouds | AWS only | AWS only | AWS, Azure, Google Cloud, SaaS, and more |
| Rollback | Automatic on failure | Automatic (via CloudFormation) | No automatic rollback; fix forward |
| Preview changes | Change sets | cdk diff | terraform plan |
Choose CloudFormation when…
- You want AWS's native, fully managed option with no extra tooling.
- Templates are fairly simple, or you're using AWS SAM for serverless apps.
Choose CDK when…
- Your team prefers real programming languages, with loops, functions, types, and autocompletion.
- You want high-level constructs that set sensible defaults and least-privilege permissions for you.
Choose Terraform when…
- You manage more than just AWS (other clouds, DNS providers, monitoring tools) from one workflow.
- Your team or company already standardizes on it.
Note
Terraform moved to a source-available license in 2023, and the community fork OpenTofu remains open source. Check which one your organization prefers.
Tip
The best IaC tool is the one your team will actually use consistently. Any of these beats clicking in the console.
Learn more: What is Infrastructure as Code?, Anatomy of a template, and AWS CDK in real code.
Key takeaways
- CloudFormation: native and fully managed, written in YAML or JSON.
- CDK: real programming languages, generating CloudFormation.
- Terraform: multi-cloud with a state file you manage.