Definition: AWS infrastructure-as-code framework that lets you define cloud resources using programming languages like TypeScript, Python, or Java instead of YAML or JSON.
— Source: NERVICO, Product Development Consultancy
What is AWS CDK
AWS CDK (Cloud Development Kit) is an open-source framework for defining cloud infrastructure using general-purpose programming languages like TypeScript, Python, Java, or C#. Instead of writing declarative templates in YAML or JSON (like CloudFormation or Terraform), developers use the same tools, patterns, and languages they already build applications with. CDK synthesizes the code into CloudFormation templates that AWS executes to create resources.
How it works
Developers write code using constructs, which are reusable components representing AWS resources. There are three construct levels: L1 (direct CloudFormation mapping), L2 (abstractions with sensible defaults), and L3 (complete patterns combining multiple resources). For example, an L3 construct can create an API Gateway with Lambda, DynamoDB, and necessary IAM permissions in just a few lines. Running cdk deploy synthesizes the code into a CloudFormation template and deploys it automatically.
Why it matters
Declarative IaC tools like CloudFormation or Terraform require learning a specific language and lack the abstraction, composition, and reuse capabilities of a real programming language. CDK allows creating reusable infrastructure components, applying conditional logic, using loops, and benefiting from IDE autocompletion and type checking. This reduces errors and accelerates the definition of complex infrastructure.
Practical example
A team needs to create identical environments for development, staging, and production. With CDK in TypeScript, they define a BackendStack class that includes an API Gateway, three Lambda functions, a DynamoDB table, and an SQS queue. For each environment, they instantiate the same class with different parameters (table size, Lambda memory, domain name). Three complete environments are created by running a single command, with the guarantee they are structurally identical.