The AWS Cloud Development Kit (CDK) is an open-source software development framework that lets you define cloud infrastructure using general-purpose programming languages — TypeScript, JavaScript, Python, Java, C#, and Go — which the CDK then synthesizes into AWS CloudFormation templates for deployment. It sits squarely in the infrastructure-as-code (IaC) space and is AWS's primary answer to the developer-productivity limitations of writing raw YAML or JSON. The key insight that separates CDK from declarative IaC tools is that your infrastructure is real code: you get loops, conditionals, type-checking, unit tests, and package managers to compose and share reusable building blocks called constructs. Because CDK compiles to CloudFormation under the hood, it inherits CloudFormation's change-set model, resource limits (500 per stack), and eventual consistency behavior — understanding that contract is what separates smooth CDK users from frustrated ones.
What This Cheat Sheet Covers
This topic spans 18 focused tables and 114 indexed concepts, 103 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Construct Levels (L1 / L2 / L3)
Constructs are the core abstraction in CDK — composable classes that represent one or more AWS resources. They are organized into three abstraction levels, and choosing the right level for each situation is the single most important CDK design decision.
| Type | Example | Description | |
|---|---|---|---|
new s3.CfnBucket(this, 'Bucket', { bucketName: 'my-bucket' }) | • Direct 1-to-1 mapping to a CloudFormation resource • named Cfn<ResourceType>• no defaults, full control over every property | ||
new s3.Bucket(this, 'Bucket', { encryption: BucketEncryption.KMS }) | Intent-based API that wraps one CloudFormation resource with sensible defaults, best-practice security policies, and helper methods (grants, metrics, event notifications). Most commonly used level. | ||
new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Svc', { ... }) | • Opinionated combination of multiple resources that deliver a complete architecture • fewest lines of code for the most infrastructure | ||
class MyTable extends Construct { constructor(...) { new dynamodb.Table(...); new cloudwatch.Alarm(...); } } | • Build your own L2/L3 by composing lower-level constructs into a reusable class • preferred over inheritance | ||
new MyConstruct(this, 'Id', { prop: 'value' }) | All constructs take three params: scope (parent), id (unique within scope), props (configuration object). | ||
new s3.Bucket(this, 'B').with(s3.mixins.AutoDeleteObjects()) | • Composable features applied to L1 or L2 constructs with .with()• adds functionality without switching construct level |