• AWS
  • Infrastructure
  • Cloud Engineering

AWS CDK vs Terraform in 2026: A Practitioner's Honest Take

Both AWS CDK and Terraform are mature, production-proven tools. Most comparisons are written by advocates of one or the other, or hedge everything with “it depends on your context.” This is an honest take from a team that has used both extensively — including building production infrastructure for AWS-native organisations with each.

The short version: we use CDK for our own infrastructure and recommend it to most of the AWS teams we work with. But Terraform is the right answer in several common situations, and we will say so plainly.

Where Terraform wins

Multi-cloud and hybrid environments. If your infrastructure spans AWS, Azure, GCP, or significant on-premises footprints, Terraform’s provider ecosystem is unmatched. CDK has escape hatches for non-AWS resources but they are genuinely painful to use. Terraform was built for this.

Teams with strong existing HCL investment. Rewriting working infrastructure is almost never worth the cost. If your team has years of Terraform modules, well-understood state management practices, and engineers who think in HCL, switching to CDK introduces risk for limited gain.

Infrastructure teams separated from application teams. When a dedicated platform or infrastructure team serves multiple application teams using different languages and stacks, a vendor-neutral, language-neutral tool is valuable. HCL is a lowest common denominator in the best sense — everyone can read it, regardless of whether they primarily write Python, Java, or Go.

The Terraform registry. For non-AWS resources — SaaS providers, monitoring tools, DNS providers, database vendors — the Terraform registry has providers that CDK simply does not. If your infrastructure includes Datadog, Cloudflare, PagerDuty, or Snowflake, Terraform will save you significant integration work.

Where CDK wins

AWS-native shops. This describes most startups and scale-ups. If your entire infrastructure lives in AWS and your team writes Python or TypeScript, CDK is a materially better tool. Not slightly better — significantly better.

Infrastructure and application code in the same repository. When your Lambda functions, your ECS task definitions, and the application code they run live in the same repo, CDK lets you reference application code directly from infrastructure definitions. The feedback loop is tighter. The separation between “what deploys” and “what runs” disappears.

Real programming constructs. This is where the day-to-day difference becomes concrete. Generating ten S3 buckets with slightly different configurations in Terraform involves for_each, count, dynamic blocks, and local values that require knowing Terraform’s peculiar evaluation model. In CDK, it is a for loop in a language you already know. Conditionals, abstractions, helper functions — all of these are available without learning workarounds.

L2 and L3 constructs. CDK’s higher-level constructs encode AWS best practices by default. Creating a VPC with sensible subnet configuration, a CloudFront distribution with correct cache policies, or an RDS instance with encryption enabled requires less domain-specific knowledge than the equivalent Terraform. The defaults are better.

Type safety. CDK catches a class of mistakes at compile time that Terraform only surfaces during plan or apply. Passing a bucket ARN where a bucket object is expected, referencing a property that does not exist on a construct — these fail before you deploy anything. On large infrastructure codebases, this matters more than it seems.

The real difference nobody talks about

CDK is a library. Terraform is a DSL.

Libraries compose. You write a function, import it elsewhere, extend it, override it, test it in isolation. The mental model is familiar to any software engineer.

DSLs are closed systems. Terraform’s HCL is expressive enough to handle most cases, but it was designed to describe infrastructure, not to compute it. When your requirements exceed what HCL was built for, you write workarounds — null_resource, external data sources, local-exec provisioners, complex templatefile expressions. The workarounds work, but they accumulate.

For simple, stable infrastructure — a handful of VPCs, some EC2 instances, an RDS cluster — this difference rarely surfaces. For complex, evolving infrastructure with significant conditional logic, reusable modules, and non-trivial abstractions, CDK’s library model is a structural advantage.

The honest downsides of CDK

CloudFormation underneath everything. CDK synthesises to CloudFormation, which means slower deployments than Terraform’s direct API calls. Stack limits of 500 resources are real. Error messages from CloudFormation are often confusing without knowing what the synthesised template looks like. cdk deploy on a large stack with multiple custom resources can take ten minutes. Terraform is faster.

Bootstrapping overhead. Before you can deploy anything with CDK, you bootstrap the account and region. This is a one-time cost but it surprises people the first time, and in multi-account AWS organisations it requires orchestration.

CDK update cadence. AWS releases CDK updates frequently. The construct APIs evolve, deprecations arrive, and keeping a large codebase current requires genuine maintenance effort. This is a real ongoing cost.

The honest downsides of Terraform

HCL’s “almost a programming language” problem. HCL can express complex logic, but the further you push it, the more it fights you. Modules with many conditional inputs, dynamic blocks nested three levels deep, complex for expressions over maps — these are all possible but produce code that is significantly harder to read and debug than equivalent Python or TypeScript.

State file management. The Terraform state file is a single point of truth that must be stored remotely, locked during operations, and kept consistent with deployed infrastructure. In teams with multiple engineers, state locking contention, state drift, and terraform state manipulation become routine operational concerns. CDK hands this problem to CloudFormation, which handles it reliably if opaquely.

The OpenTofu situation. The fork of Terraform following HashiCorp’s licence change in 2023 has created genuine uncertainty. OpenTofu is a credible project, but organisations now have to choose between the commercial HashiCorp product and the open-source fork, and that choice involves long-term bets on community momentum and enterprise support. This is not a reason to avoid Terraform, but it is a factor that did not exist three years ago.

The recommendation

If you are an AWS-native team and your engineers are comfortable in Python or TypeScript, use CDK. The productivity gains from real programming constructs and type safety, the tighter integration with AWS services, and the ability to share infrastructure code across your codebase compound over time.

If you are multi-cloud, have a dedicated infrastructure team serving multiple application teams, or are migrating from an existing Terraform estate that is working well, use Terraform. The cost of switching from a functioning Terraform setup to CDK is rarely justified.

The worst outcome is not picking the wrong tool. It is picking a tool and using it badly — treating CDK like a YAML generator, or using Terraform modules as copy-paste templates — because the team never invested in understanding the underlying model. Either tool, used well, will serve you. Either tool, used as a black box, will become a liability.

Cloudomation helps engineering teams adopt AI development tools with the discipline and guardrails to make the results sustainable.

Book a free Assessment →