Understanding Constructs
The heart of AWS CDK lies in Constructs. These are the basic building blocks of your cloud application, representing cloud components and their configurations. They are essentially classes within your programming language that define infrastructure resources.
Constructs come in three distinct “levels” of abstraction:
- L1 Constructs (Low Level) - These map directly to individual AWS resources. They are ideal when you need complete, granular control over every single property of a resource.
- L2 Constructs (Curated) - These provide higher-level, intent-based APIs with sensible defaults and built-in best practices. For example, an L2 S3 bucket construct might automatically enable encryption and versioning by default. This is the most widely used construct type.
- L3 Constructs (Patterns) - These are high-level abstractions designed to help you quickly define complex, well-architected solutions. A single L3 construct might combine multiple L1 and L2 resources — such as an Application Load Balancer with a Fargate Service — using minimal code.