Skip to content
Latchkey

AWS CDK vs Terraform: Which IaC Tool?

AWS CDK defines AWS infrastructure in real programming languages and synthesizes CloudFormation; Terraform uses declarative HCL across many providers and clouds.

CDK lets you author AWS infrastructure in TypeScript, Python, or other languages, using loops, abstractions, and constructs, then synthesizes CloudFormation under the hood, deeply AWS-native. Terraform uses declarative HCL with a vast provider ecosystem spanning AWS, GCP, Azure, and SaaS, with its own state model. CDK favors language-native AWS authoring; Terraform favors multi-cloud declarative breadth.

AWS CDKTerraform
StyleImperative (real code)Declarative (HCL)
ScopeAWS (CloudFormation)Multi-cloud + SaaS
AbstractionConstructs, language featuresModules
StateCloudFormation-managedTerraform state
Best forAWS-only, code-first teamsMulti-cloud, declarative

Use case and scope

CDK suits AWS-only teams who prefer real programming languages, reusable constructs, and CloudFormation-managed state. Terraform suits multi-cloud or SaaS-spanning infrastructure and teams who prefer declarative HCL with a huge provider ecosystem. CDK leans into AWS; Terraform spans providers and is cloud-agnostic.

In CI

Both run plan/diff and apply from CI using OIDC for keyless AWS auth; gate apply behind review. Either runs on managed runners, where faster runners shorten synth/plan and apply steps.

The verdict

AWS-only and preferring real programming languages and constructs: AWS CDK. Multi-cloud, SaaS-spanning, or declarative-HCL preference: Terraform. CDK is excellent for code-first AWS shops; Terraform is the broader, cloud-agnostic choice.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card