Terraform or AWS CDK: which should a small team use?
By the Keel team · Last checked · 5 min read
Short answer
For most small teams, Terraform (or its open-source alternative OpenTofu) is the safer default, because more engineers already know it and the same workflow covers providers beyond AWS. AWS CDK is a good choice if your team writes TypeScript or Python, works only on AWS and wants infrastructure in the same language as the application. Whichever you pick, the habits matter more than the tool: everything in Git, every change reviewed, and nothing changed by hand in the console.
How do Terraform and AWS CDK differ?
The practical differences are the language, the scope and where the record of what exists is kept.
AWS describes the CDK as an open-source framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation, with support for TypeScript, JavaScript, Python, Java, C# and Go.
| Terraform / OpenTofu | AWS CDK | |
|---|---|---|
| Language | HCL, a purpose-built configuration language | TypeScript, JavaScript, Python, Java, C# or Go |
| Scope | AWS plus other providers, such as GitHub | AWS resources |
| Record of what exists | A state file you store, for example in S3 | CloudFormation stacks |
| Preview a change | terraform plan | cdk diff |
| Rollback on a failed deploy | No automatic rollback; you fix forward or re-apply | CloudFormation rolls back on error |
AWS's own example of a CDK app that defines an ECS Fargate service with a VPC and load balancer produces a CloudFormation template of more than 500 lines. That is the appeal of CDK: a few lines of code expand into a large, consistent set of resources.
Which should a team of 3 to 15 developers choose?
Choose Terraform or OpenTofu unless you have a specific reason to prefer CDK.
It is the more common skill, so it is easier to hire for, easier to hand to a contractor or provider, and one tool can manage AWS, GitHub and other services you already use.
The deciding question is who will own the infrastructure in a year. If a dedicated person or a provider will look after it, pick the tool that is easiest for them to take over. If the application developers will own it and they already work in TypeScript or Python every day, CDK removes a language they would otherwise have to learn.
Do not run both against the same resources. Two tools managing one environment leads to drift and arguments about which is right. Pick one per environment and write the decision down.
When does Terraform or OpenTofu win?
Terraform or OpenTofu wins when your infrastructure reaches beyond AWS, when you expect outside people to work on it, or when you want a plan that reads clearly in a pull request.
- You manage more than AWS, such as repository settings on GitHub, DNS or monitoring.
- You may bring in a contractor, an auditor or a managed provider, who are more likely to know HCL than your CDK constructs.
- You want reviewers who are not infrastructure specialists to read a plan and spot a resource being destroyed.
- You want the record of what exists in a state file you control, rather than inside CloudFormation.
OpenTofu is an open-source alternative with a compatible workflow, and its S3 backend supports the same style of remote state described in how to lock Terraform state in S3 without DynamoDB.
When does AWS CDK win?
AWS CDK wins when your team is all-in on AWS, comfortable in a supported programming language and wants to build reusable components the way it builds application libraries.
- Developers will own infrastructure and prefer loops, functions and types to configuration blocks.
- You only use AWS, so a single provider scope is not a limit.
- You want CloudFormation's deployment model, including rollback on error, without writing raw templates.
- You already have tests and linting set up for your language and want to reuse them.
AWS says that because CDK deploys through CloudFormation you get predictable, repeatable deployments and do not need to learn a separate infrastructure service. The trade-off is that your infrastructure is now a program, so a clever abstraction can hide what will actually change. Read the synthesised output when reviewing.
Where should Terraform state live?
Terraform state should live in a remote backend with locking, such as an S3 bucket with versioning and encryption on, never only on a laptop.
State can contain sensitive values, so restrict access to the roles that run Terraform and keep each environment in its own state.
Separate state per environment means a mistake in staging cannot touch production. For production, a separate AWS account for state is a sensible extra layer, as covered in how many AWS accounts a startup needs. CDK has no state file to manage, because CloudFormation holds the record, which is one less thing to look after.
How should infrastructure changes be reviewed?
Treat infrastructure like application code: every change goes through a pull request, CI shows what will change, and a second person reads that preview rather than just the diff.
- Open a pull request for every change.
- Let CI run
terraform plan(orcdk diff) and post the result on the pull request. - Have a second person read the plan, looking hardest at anything it will destroy or replace, such as a database.
- Apply from CI after merge, not from a laptop.
- run: terraform init -input=false
- run: terraform plan -input=false -out=tfplan
# after review and merge, a separate job runs:
- run: terraform apply -input=false tfplanCI should reach AWS without long-lived keys; GitHub Actions to AWS with OIDC shows how. The same discipline is what protects you when the engineer who built your AWS setup leaves.
How do you bring existing resources under management?
Bring existing resources under management gradually, starting with the riskiest ones, so that the production database and networking are protected by review before anything else changes.
Both tools can adopt resources that were created by hand: Terraform through its import feature, and CDK through its import command. Check each tool's documentation for the current syntax before you begin. After an import, run a plan or diff and expect to adjust the code until it reports no changes. Only then treat the resource as managed, and stop editing it in the console.
Is your infrastructure as code safe to hand over?
Tick each item that is true today.
- Every environment is defined in code in Git.
- Nobody changes production by hand in the console.
- Each change goes through a pull request with its plan or diff.
- Apply runs from CI, not from a laptop.
- Terraform state is remote, locked and separate per environment.
- More than one person can explain how it works.
Decision point: Five or six ticks: your setup survives a change of staff. Three or fewer: the next departure or outage will be expensive.
Sources
- AWS docs, What is the AWS CDK? (checked November 2026)
- HashiCorp, Terraform S3 backend (checked November 2026)
- OpenTofu docs, S3 backend (checked November 2026)
Keep reading
Keel is an AWS release and recovery operations service for SaaS teams of 3 to 15 developers, provided by Bargainn Services Ltd, a UK company registered at Companies House (16497746). Registered office: 3rd Floor, 86-90 Paul Street, London, EC2A 4NE, United Kingdom.