AWS CDK
AWS CDK (Cloud Development Kit) lets you define cloud infrastructure using familiar programming languages (TypeScript, Python, Java, C#). CDK code synthesizes into CloudFormation templates, combining the power of real code with CloudFormation's resource management.
CDK is a smart architect who speaks your language (TypeScript/Python) and writes the building permits (CloudFormation templates) for you. L2 constructs are pre-designed rooms with walls, electricity, and plumbing included.
Core concepts: App (root), Stacks (unit of deployment), Constructs (reusable components). L1 Constructs: direct CloudFormation resource mappings (CfnBucket). L2 Constructs: high-level abstractions with sane defaults (s3.Bucket). L3 Constructs (Patterns): opinionated combinations (aws-solutions-constructs). CDK bootstrapping sets up the CDK toolkit resources (S3 bucket, ECR repo, IAM roles) in a target account. cdk synth generates CloudFormation templates; cdk deploy deploys them.
CDK Aspects apply visitor pattern logic across the entire construct tree — useful for enforcing security policies (all S3 buckets must have versioning) across all stacks. CDK Pipelines provides a self-mutating CI/CD pipeline that updates itself when the CDK app changes. CDK Assets handle bundling and uploading Lambda code or Docker images. The CDK CLI uses the CDK toolkit stack to track deployed asset versions. CDK Nag (community library) runs security and compliance rules against CDK apps, similar to cfn-nag. Environment-specific stacks (prod vs staging) use environment variables or context values to parameterize constructs.
CDK lets me write infrastructure in TypeScript with real abstractions, loops, and type checking — far more maintainable than raw CloudFormation YAML for complex architectures. L2 constructs have sane security defaults. I use CDK Aspects for org-wide security policies (force encryption, tag all resources) and CDK Pipelines for self-updating deployment pipelines. CDK still synthesizes to CloudFormation, so all CloudFormation features and limitations apply.
Assuming CDK bypasses CloudFormation limits. CDK just generates CloudFormation — the 500-resource limit, change set behavior, and rollback mechanics still apply. Large CDK apps need nested stacks just like raw CloudFormation.