AWS CloudFormation là Infrastructure as Code (IaC) service, định nghĩa AWS resources bằng YAML/JSON templates, deploy và manage infrastructure theo stack; hỗ trợ rollback tự động khi deploy fail, drift detection, change sets (preview thay đổi trước khi apply), nested stacks, cross-stack references.
AWS CDK (Cloud Development Kit) là framework cho phép định nghĩa infrastructure bằng ngôn ngữ lập trình quen thuộc (TypeScript, Python, Java, Go, C#); CDK synthesize thành CloudFormation template, sau đó deploy bình thường.
CDK mạnh hơn CloudFormation thuần vì: code abstraction (loops, conditions, functions thay vì repeat YAML), Constructs library cung cấp high-level patterns (L2/L3 constructs như aws-ecs-patterns.ApplicationLoadBalancedFargateService), type safety và IDE autocomplete, unit testing infrastructure code bằng Jest.
Nên dùng CDK khi: team biết lập trình, infrastructure phức tạp cần abstraction, muốn reuse patterns qua constructs, cần generate nhiều tài nguyên tương tự. Nên dùng CloudFormation thuần khi: team không muốn học CDK, template đơn giản, cần maximum transparency. Terraform là alternative multi-cloud (không lock-in AWS), Pulumi tương tự CDK nhưng multi-cloud.