PROVIDER - Define AWS resources in code
AWS CDK
AWS CDK lets developers define AWS resources in 6 languages, synthesising CloudFormation templates that reuse native deployment while official constructs cover 200+ services; the boundaries are tight AWS coupling and a steeper learning curve than YAML templates.
4.4pts
Service Overview
AWS CDK (Cloud Development Kit) is Amazon's official infrastructure as code framework. Developers describe resources in a high-level language, and the CDK synthesises a standard CloudFormation template that AWS then executes.
In the development tools category it represents the "infrastructure in a programming language" route: unlike Terraform's declarative HCL, the CDK leans on a language's type system, loops and package management to model complex topologies.
Key Strengths
- Multi-language: 6 options including TypeScript, Python, Java, C# and Go
- Native deployment: synthesises CloudFormation and inherits AWS rollout and rollback
- Three abstraction tiers: L1 resources, L2 conveniences and L3 patterns as needed
- Construct ecosystem: 200+ services officially, extended by Construct Hub
- Type safety: attribute validation and completion directly in the editor
Product Ecosystem
Platform capabilities
Resource modelling, template synthesis, change diffing, environment bootstrapping, multi-stack organisation and cross-account deployment.
Integrations
Works with AWS CodePipeline, GitHub Actions, CDK for Terraform, Projen and standard test frameworks.
Typical scenarios
Applications and data pipelines on AWS, platform teams packaging reference architectures, and unified delivery across environments and accounts.
Limitations
- Platform coupling: optimised for AWS, so cross-cloud work needs abstraction
- High-level ceilings: L3 constructs trade flexibility for convenience
- Learning barrier: programming skills are a prerequisite for the team
- Debug depth: issues often require reading the generated template layer
Use Cases
- AWS-native projects (★★★★★): the language and platform pairing is smoothest here
- Complex topology modelling (★★★★★): loops and functions express repetition cleanly
- Platform team packaging (★★★★☆): publish standard architectures as construct libraries
- Cross-cloud infrastructure (★★☆☆☆): Terraform-style tools fit better
Pricing
| Item | Price | Notes |
|---|---|---|
| AWS CDK | $0 | Apache 2.0 open source, free to use |
| CloudFormation | $0 | No extra charge; resources bill by usage |
| Bootstrap resources | Usage based | Normal costs for S3, IAM and ECR |
FAQ
How does CDK relate to CloudFormation templates?
CDK is the authoring layer; the output is a standard CloudFormation template that performs the deployment.
How do I choose between CDK and Terraform?
Choose CDK for deep AWS use with a programming-fluent team; choose Terraform for unified multi-cloud management.
Are custom resources supported?
Yes. L1 constructs, custom resources and property overrides extend coverage beyond the official library.
Can changes be previewed locally?
Yes. cdk diff prints the resource changes that would occur, which supports pre-deployment review.
Code Examples
import * as cdk from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
export class DemoStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// L2 construct applies secure defaults automatically
new s3.Bucket(this, 'Assets', {
versioned: true,
encryption: s3.BucketEncryption.S3_MANAGED,
removalPolicy: cdk.RemovalPolicy.RETAIN,
});
}
}
# Bootstrap the account and deploy
cdk bootstrap aws://123456789012/us-east-1
cdk diff
cdk deploy
Community & Resources
- Website: https://aws.amazon.com/cdk/
- Source repository: https://github.com/aws/aws-cdk
- Construct Hub: https://constructs.dev/
Articles
- 01 GitLab CI/CD Best Practices: From Beginner to Production-Grade Pipelines 07-18
- 02 Prometheus Monitoring System Setup: From Metric Collection to Alert Notifications 07-18
- 03 Ansible Automation Ops Guide: From Configuration Management to Application Deployment 07-18
- 04 Docker Beginner Tutorial: From Installation to Containerized Web Deployment 07-18
- 05 Developer Tools Panorama: What Version Control, Package Managers, CI/CD and Containers Solve 08-12
- 06 Upgrading SVN to 1.8 on CentOS 7 04-02
- 07 Git for Beginners: Working Directory, Staging Area, Repository and Core Commands 08-12
- 08 GitHub Actions CI/CD Tutorial: Automated Build, Test, and Deployment 07-18
- 09 GitHub Copilot Code Review Is Now Generally Available 08-05
- 10 API Integration Guide: REST vs GraphQL Comparison and Selection 07-18