CloudConsole

AWS CDK vs Terraform

Updated 17 November 2026 · How we write and check guides

Short answer

Choose the AWS CDK when your team are developers who want to define AWS infrastructure in TypeScript, Python, Java, C# or Go, with high-level constructs that wire up IAM and networking for you, and you are happy for CloudFormation to deploy it. Choose Terraform when you manage several clouds or SaaS providers, prefer declarative HCL that operations teams read easily, or need one tool for everything.

AWS CDK vs Terraform: deciding factors Language, Abstraction, Deployment engine, State; When the CDK is the better choice /…
The deciding factors from this page's comparison table, and the cases where each option wins.

CDK vs Terraform compared

FactorAWS CDKTerraform
LanguageTypeScript, JavaScript, Python, Java, C#/.NET, GoHCL
AbstractionL1 (raw CloudFormation), L2 (sensible defaults), L3 patternsResources and modules
Deployment engineSynthesises CloudFormation templates and deploys stacksTerraform core calls provider APIs directly
StateCloudFormation stacksState file you store and lock
RollbackCloudFormation automatic rollbackNo automatic rollback
Previewcdk diff (and change sets)terraform plan
ProvidersAWS (third-party through CloudFormation registry)AWS and many others
SetupBootstrap each account and Region (S3 bucket, ECR repository, IAM roles)Backend for state (for example S3 with locking)

When the CDK is the better choice

  • Application teams who already write TypeScript or Python and want infrastructure in the same repository, tested with the same tools.
  • You want L2 constructs that generate least-privilege IAM grants (bucket.grantRead(fn)) and sane defaults instead of writing every property.
  • Repeated patterns across many services, packaged as your own construct library.
  • You want CloudFormation's managed state and rollback without writing YAML.

When Terraform is the better choice

  • Your estate spans AWS plus other clouds or SaaS (DNS, CDN, monitoring, source control).
  • Platform or operations teams who want readable, declarative configuration rather than a program that generates it.
  • You need fine control over individual resources and imports without CloudFormation's quotas and stack boundaries.

Be explicit about state: store it remotely with locking and encryption, restrict who can read it, and plan how you will split it as the estate grows.

Migrating or mixing

CDK and Terraform can coexist in one organisation as long as each resource has one owner. To bring existing CloudFormation templates into the CDK, use CfnInclude; to generate a CDK app from deployed resources, the CDK Migrate feature (in preview) builds on CloudFormation's IaC generator. Moving from CDK to Terraform means retaining resources in CloudFormation, removing them from the stack and importing them into Terraform.

Common wrong reasons

  • "CDK avoids CloudFormation limits." It deploys CloudFormation, so stack quotas and update behaviour still apply.
  • "Terraform cannot be tested." It has a built-in test framework and plan-based policy checks; CDK has assertions on synthesised templates.
  • "Code is always better than config." Loops and conditionals help, but clever infrastructure code is harder to review during an incident.

Questions

Is AWS CDK better than Terraform?

For AWS-only teams of developers who want typed code and high-level constructs, often yes. For multi-provider estates or teams that prefer declarative configuration, Terraform is usually the better fit.

Does the CDK use CloudFormation?

Yes. The CDK synthesises CloudFormation templates and deploys them as stacks, so CloudFormation handles state and rollback.

Do I need to bootstrap for CDK?

Yes. Each account and Region must be bootstrapped once, which creates an S3 bucket, an ECR repository and IAM roles used for deployments.

When this happens away from your desk

When an infrastructure deploy breaks production, you want the failing resource and the change that triggered it, not the whole pipeline log. CloudConsole is being built to show deploy events and alarms on a phone with production guardrails.

About the app → · Download on the App Store

Sources