Introduction to AWS CDK: When to Use It Over Terraform

I write Node that talks to the cloud, React that talks to users, and systems that talk to each other — seamlessly.
When I first started automating infrastructure on AWS, I didn’t want to deal with writing giant YAML or JSON templates by hand. That’s where the AWS Cloud Development Kit (CDK) clicked for me. CDK lets me write infrastructure in TypeScript, which is the same language I use for most of my application code. It feels natural, it’s expressive, and I get to use the full power of a programming language — loops, conditions, functions — to define my infra.
What is CDK?
At its core, CDK is an Infrastructure as Code (IaC) framework. Instead of manually writing CloudFormation templates, you define your resources (like S3 buckets, Lambda functions, DynamoDB tables) using code. CDK then compiles that into CloudFormation under the hood and handles the deployment.
So in short:
I write infra in code.
CDK converts it into CloudFormation.
CloudFormation applies it to AWS.
That abstraction layer is what makes CDK so convenient.
How Does Terraform Fit In?
I haven’t used Terraform myself, but I often hear it compared with CDK. The way I see it:
Terraform is a widely used, declarative tool that works across multiple cloud providers.
CDK is tightly integrated with AWS and gives you the flexibility of coding infra in a real language.
If your team works across AWS + Azure + GCP, Terraform might make more sense. But if you’re deep in AWS (like me), CDK feels like a natural extension of app development.
CDK in 5 Basic Commands
The workflow with CDK is super simple. Most of the time I only use these five commands:
cdk init– start a new project (I usually pick TypeScript).cdk synth– see the CloudFormation template CDK generates.cdk diff– check what’s about to change in your infra before deploying.cdk deploy– apply the changes to AWS.cdk destroy– tear it all down if you don’t need it anymore.
That’s basically the lifecycle — define → preview → deploy → clean up.
Why I Prefer CDK
For me, CDK works best when:
I want my infra and application logic in the same language.
I need dynamic infra generation (like looping through configs to create multiple S3 buckets).
I want strong AWS-native support without extra layers.
The productivity boost I get from not context-switching between TypeScript and HCL/YAML is huge.
