Get things done in the cloud, AWS is easy when you use CDK
I am known to like power tools. All the gadgets at Home Depot make my eyes bug out.
CDK
The first time someone explained AWS CDK to me it sounded pretty powerful. I was excited to learn more.
It seemed so esoteric and hard to learn. Once I kicked the tires a bit I realized it was pretty straightforward.
CDK workshop
AWS has a CDK Workshop that gives you the baby steps to knowledge. Plus you can choose the language you would like to use.
It walks you through the basic project setup. Then you learn how to modify and deploy your changes. Simple and confidence-boosting!
The CDK book
Once you run through the workshop you have your sea legs. Then you can dig deeper with the CDK Book. It covers a lot for thirty-nine dollars. If you have any doubts look at the table of contents.
AWS CDK Crash Course
In this hour-long crash course, Matt Martz covers CDK Basics. He starts with definitions, constructs, and assets. Then moves to more advanced topics.
AWS Examples
In this post, Manoj does a great job of sharing examples. He also covers levels of constructs. This clues you in on how CDK builds upon itself. They use lower-level AWS components to create the stacks.
You get to create a Fibonacci Generator using CDK. There is a backend REST API as well as a front-end React application. Manoj shares the code you need and explains what is happening.
Manoj also gives a CDK Crash Course here too.
CDK Benefits
The main benefit of using CDK is developer productivity. The constructs used can enable us to create quickly.
It creates what you need in CloudFormation. As you deploy often pay attention to the templates you create. CDK provides another level of abstraction.
Another benefit is the choice of languages. You can choose a language you understand or are familiar with—choices like Typescript, Python, C#, and Java.
CDK is easily customizable. You can change your stacks quickly to fit your needs. Along with that, they are also reusable. This enables an organization to reuse the common design.
CDK Use Cases
There are a few CDK Use Cases that are pretty common. Here are a few to consider.
Serverless
You can use CDK to create a Serverless function or utility. AWS Lambda can be used for many different things. From file processing to IoT and mobile backends.
Containers
Working with many microservices we have them deployed on Fargate containers. This allows us to scale to our needs. We can set up to add service per load demand.
CDK Core Concepts
AWS has designed CDK with stunning simplicity. There are two key parts.
Stacks
The stacks are from CloudFormation. This is the backbone of everything done in CDK. Essentially CDK is a thin veil around CloudFormation. The stacks can consume resources from other stacks.
Constructs
Along with the stacks CDK has constructs. These are building block resources.
The stacks create constructs for high and low-level components. For instance, an S3 bucket is a level one. Level 2 constructs incorporate additional functionality. Our S3 bucket would be able to add a lifecycle.
There are Level 3 constructs that enable patterns. These can allow you to set up an AWS Fargate cluster.
Secret Sauce
CDK’s secret sauce is that it allows developers to use a familiar language. While behind the scenes it translates it to CloudFormation templates. This enables the productivity I highlighted before.
Overall CDK is a great power tool for developers. There are many ways it can be leveraged. Another nice thing is they are always releasing new features. So it continues to get better.