AWS CDK Constructs

AWS CDK provisions your resources in a safe, repeatable manner through AWS CloudFormation.

Constructs are the basic building blocks of AWS CDK apps. A construct represents a "cloud component" and encapsulates everything AWS CloudFormation needs to create the component.

AWS CDK supports three types of constructs, you are not tied to one specific construct for you stack deployment. You can use a combination of the below to build your CDK application.

Level 1 (L1) construct

These are direct representations of CloudFormation resources. When you choose L1 constructs you must provide all the required CloudFormation attributes for a particular cloud resource.

Level 2 (L2) construct

A Level 2 construct also represents a particular cloud resource. E.g. An S3 bucket. But you don’t have to configure every configuration attribute. Instead, they are provided with convenient default values such that you can easily spin up a certain cloud resource.

Level 3 (L3) construct

A Level 3 construct represents a bunch of cloud resources that work together to accomplish a particular task. They are also called “patterns”. For example, you can create an ApplicationLoadBalancedFarageteService which will create an ECS cluster powered by Fargate, an ECR repository to host your Docker images, Application Load Balancer to access your containers, etc…

In addition to that, AWS best practices are baked into these patterns so that you can use them for production use directly.