About 24; min
Terraform and CloudFormation are the two most-used infrastructure-as-code tools on AWS. Terraform works with every cloud. CloudFormation is AWS-only but free and deeply integrated. CDK (Cloud Development Kit) sits on top of CloudFormation, letting you write infrastructure in TypeScript or Python instead of YAML.
If you’re building on AWS, the choice between these three affects your team’s productivity, hiring, and long-term flexibility. Here’s how they compare in 2026.
Quick Pricing Comparison
| Tool | CLI Cost | Cloud Platform Cost | License |
|---|---|---|---|
| Terraform | Free (CLI) | $0.00014/resource-hour (Terraform Cloud) | BSL (source-available) |
| OpenTofu | Free | N/A (self-manage state) | MPL 2.0 (open source) |
| CloudFormation | Free | Free (included with AWS) | Proprietary (AWS) |
| AWS CDK | Free | Free (generates CloudFormation) | Apache 2.0 |
CloudFormation and CDK are completely free — no per-resource charges, no platform fees. Terraform CLI is free but Terraform Cloud charges per managed resource. For AWS-only teams, CloudFormation/CDK has a clear cost advantage.
CloudFormation: Free and AWS-Native
CloudFormation costs nothing. Zero. AWS includes it as part of the platform. You write YAML (or JSON) templates that describe your AWS resources, and CloudFormation creates, updates, and deletes them. For a team managing 5,000 AWS resources, Terraform Cloud would cost ~$5,040/month. CloudFormation costs $0.
CloudFormation’s Strengths
- Zero cost: No subscription, no per-resource fees, no state management charges. The most cost-effective IaC option for AWS
- Same-day AWS support: New AWS services are available in CloudFormation on launch day. Terraform providers sometimes lag by days or weeks
- Drift detection: CloudFormation can detect when someone manually changes a resource outside of IaC and show you the drift. Terraform requires paid plans for this
- StackSets: Deploy infrastructure across multiple AWS accounts and regions from a single template. Essential for organizations with landing zone architectures
- Rollback: Failed deployments automatically roll back to the previous working state. Terraform doesn’t have automatic rollback — failed applies leave resources in partial states
CloudFormation’s Pain Points
- YAML/JSON verbosity: A simple VPC with subnets, route tables, and NAT gateways can be 300+ lines of YAML. The same in Terraform HCL is 100 lines. In CDK TypeScript, it’s 30 lines
- AWS-only: CloudFormation manages AWS resources exclusively. If you use any other cloud, SaaS API, or DNS provider, you need a separate tool
- Slow updates: CloudFormation stack updates are sequential and can take 10–30 minutes for large stacks. Terraform parallelizes resource creation and typically finishes faster
- Error messages: CloudFormation’s error messages are notoriously unhelpful. “Resource creation failed” without telling you why is a daily frustration
- State management: CloudFormation manages state internally (no state files), which is simpler but means you can’t inspect or modify state directly when things go wrong
AWS CDK: CloudFormation in Real Code
CDK solves CloudFormation’s verbosity problem. Instead of writing 300 lines of YAML, you write 30 lines of TypeScript (or Python, Java, C#, Go). CDK compiles your code into a CloudFormation template and deploys it through CloudFormation’s engine — you get the deployment reliability of CloudFormation with the development experience of a real programming language.
CDK Code vs CloudFormation YAML
Creating a VPC with 2 public and 2 private subnets across 2 availability zones:
CloudFormation YAML: ~150 lines (VPC, subnets, route tables, internet gateway, NAT gateway, elastic IP, route table associations)
CDK TypeScript: ~5 lines
CDK’s high-level constructs (L2/L3) bundle best practices into single function calls. The VPC construct automatically creates subnets, route tables, NAT gateways, and internet gateways with sensible defaults. You override only what you need to customize.
CDK’s Strengths
- Productivity: 5–10x less code than raw CloudFormation for the same infrastructure
- Type safety: TypeScript catches configuration errors at compile time, not during deployment
- Unit testing: Write Jest/pytest tests for your infrastructure. Assert that your stack creates the expected resources with the correct properties before deploying
- Reusable constructs: Package infrastructure patterns as libraries. Share VPC, ECS, or Lambda constructs across teams via npm/PyPI
- Familiar tooling: Your infrastructure code lives in the same repo, uses the same CI/CD, and follows the same review process as application code
CDK’s Downsides
- AWS-only: Same limitation as CloudFormation. CDK generates CloudFormation, so it only manages AWS resources
- Abstraction leaks: When something goes wrong, you debug CloudFormation errors, not CDK code. Understanding what CDK generated requires reading the synthesized CloudFormation template
- Community constructs quality varies: Third-party constructs from the Construct Hub range from production-grade to abandoned experiments. Vet carefully
- Version updates: CDK releases frequently, and breaking changes between major versions require migration effort
Terraform: Multi-Cloud Standard
Terraform’s multi-cloud support is its defining advantage. One language (HCL) manages AWS, Azure, GCP, Cloudflare, Datadog, PagerDuty, GitHub, and 3,500+ other providers. If your infrastructure spans multiple clouds or includes SaaS providers, Terraform is the only IaC tool that handles everything.
Terraform vs CDK for AWS-Only Teams
| Factor | Terraform | CDK |
|---|---|---|
| Language | HCL (learn new language) | TypeScript/Python (languages you know) |
| Code verbosity | Medium (less than CF, more than CDK) | Low (high-level constructs) |
| State management | You manage (S3 backend or Terraform Cloud) | CloudFormation manages internally |
| New AWS service support | Days-weeks after AWS launch | Same day (CloudFormation) |
| Multi-cloud support | Yes (3,500+ providers) | No (AWS only) |
| Deployment speed | Fast (parallel) | Slower (CloudFormation sequential) |
| Rollback | Manual (no auto-rollback) | Automatic (CloudFormation) |
| Cost (5K resources) | $5,040/mo (Terraform Cloud) or $0 (CLI + S3) | $0 (always free) |
| Community modules | Terraform Registry (large) | Construct Hub (growing) |
| Job market | Much larger | Growing |
For AWS-only teams: CDK is more productive (less code, familiar language, unit tests) and cheaper ($0 vs Terraform Cloud fees). Terraform makes sense only if you might add a second cloud provider or need to manage non-AWS resources (DNS, monitoring, SaaS tools).
OpenTofu: Free Terraform Fork
OpenTofu forked from Terraform when HashiCorp changed the license from MPL to BSL in 2023. It’s a drop-in replacement: existing Terraform configurations work with OpenTofu by changing the binary name. The Linux Foundation maintains it with backing from AWS, Google, and others.
For teams that want Terraform’s multi-cloud capability without Terraform Cloud costs or BSL license concerns, OpenTofu + S3 state backend is the zero-cost alternative. You lose Terraform Cloud features (team management, policies, runs UI) but save thousands per year.
Cost Comparison: 50-Person Engineering Team, 5K AWS Resources
| Tool | Tool Cost | State Management | Annual Total |
|---|---|---|---|
| CloudFormation | $0 | $0 (AWS managed) | $0 |
| CDK | $0 | $0 (CloudFormation) | $0 |
| OpenTofu + S3 backend | $0 | ~$5/mo (S3 + DynamoDB) | $60 |
| Terraform CLI + S3 backend | $0 | ~$5/mo | $60 |
| Terraform Cloud Standard | $5,040/mo | Included | $60,480 |
The range is $0 (CloudFormation/CDK) to $60,480/year (Terraform Cloud). For AWS-only teams, paying for Terraform Cloud when CloudFormation is free requires strong justification.
Who Should Pick What
Pick CloudFormation If:
- You’re AWS-only and want zero IaC costs
- Same-day support for new AWS services matters
- Automatic rollback on failed deployments is important for production safety
- StackSets for multi-account deployment is needed
- Your team is comfortable with YAML and doesn’t mind verbosity
Pick CDK If:
- You want CloudFormation’s reliability with 5–10x less code
- Your team already writes TypeScript or Python (no new language to learn)
- Unit testing infrastructure before deployment matters
- Reusable infrastructure patterns (constructs) would benefit your organization
- You’re AWS-only and want the most productive IaC experience at $0
Pick Terraform/OpenTofu If:
- You use multiple cloud providers or manage non-AWS resources
- Terraform expertise is already on your team
- The 3,500+ provider library covers services CDK/CloudFormation can’t manage
- You want the largest community, most modules, and best hiring pool
- Use OpenTofu for the same experience with open-source licensing
Best for AWS-only teams: CDK — zero cost, 5–10x less code than CloudFormation, unit testable, and uses languages you already know. The most productive AWS IaC tool in 2026.
Best for multi-cloud: Terraform/OpenTofu — the only option that manages AWS + Azure + GCP + SaaS from one tool. Use OpenTofu for open-source licensing.
Best zero-effort option: CloudFormation — free, no state management, automatic rollback. More verbose but zero operational overhead.
Avoid Terraform Cloud unless: You specifically need the team management, policy engine, and runs UI. The per-resource cost adds up fast when CloudFormation is free.
FAQ
Can I migrate from Terraform to CDK?
Yes, but it’s a rewrite — not a migration. You recreate your infrastructure definitions in CDK, import existing resources into the new CloudFormation stack, and decommission the old Terraform state. Budget 2–4 weeks for a medium-complexity AWS setup.
Is CDK production-ready?
Yes. CDK v2 is stable and used by thousands of companies in production. AWS uses CDK internally. The main risk is the rapid release cycle — pin your CDK version and upgrade deliberately.
Should I learn Terraform or CDK in 2026?
If you’ll only work with AWS: CDK. If you might work with multiple clouds or want the broadest job market: Terraform. Both are valuable skills, but Terraform has 3–5x more job listings than CDK.
What about Pulumi?
Pulumi offers multi-cloud support with real programming languages (like CDK but for all clouds). It’s a strong third option — see our Terraform vs Pulumi comparison for details. The per-member pricing ($50/user) is cheaper than Terraform Cloud at scale.




