๐ This is not properly displayed? Read all of our issues online! ๐ก
Hi Reader ๐๐ฝ
We hope you're having an amazing week!
After writing about Terraform and the Serverless Framework let's tackle Sandro's favorite framework for IAC, which is the AWS Cloud Development Kit - the CDK.
The CDK was launched back in July 2019, which makes it one of the younger Infrastructure-as-Code tools out there.
It is a so-called componentized for provisioning your resources. Check out this article to learn more about the different stages of Infrastructure-as-Code frameworks.
The main difference between CDK and declarative tools like CloudFormation is the programming language you use.
In CloudFormation, you create configuration files in YAML or JSON. In CDK, you can use a proper programming language such as Python or TypeScript.
After writing your code, CDK will transform this code into CloudFormation templates. This has two amazing benefits:
For the examples, we will use TypeScript. You can also use the examples in another language of your choice.
CDK allows us to use our own programming languages. This enables us to build abstractions. And it also allows us to use our most beloved tool, the IDE. The IDE is the Integrated Development Environment. For example, VS Code, Webstorm, or IntelliJ. What benefits does that actually bring us?
Developers love their IDEs. We are used to them. We understand shortcuts, file managers, and actions like refactoring or debugging.
It is amazing how fast developers can be with a programming language and syntax they know. The only issue in the past came with how to provision resources. These days are gone with the CDK.
The core building blocks of CDK are Constructs. Constructs can but don't have to be shared. This enables developers to create constructs and share them across the company.
For example, if you have a standardized way of creating Lambda functions with attached DLQs you can publish a construct for that.
When choosing a framework to develop your cloud infrastructure in it is important to think about the stability and future of the tool. CDK is developed and supported by AWS. This brings a great benefit compared to other tools.
The CDK follows the concept of:
Constructs are the main building blocks in CDK. You should model your application by creating constructs for the different cloud resources you need. Constructs can be reusable but donโt need to be. That means you can also create a construct that is only used once.
Constructs are differentiated into different levels.
Level 1: This is the exact CloudFormation Construct:
Level 2: Level 2 constructs have some abstractions built-in on top of Level 1 like additional APIs, and default settings. They are often much easier to work with.
Level 3: Level 3 constructs are often community-shared constructs and combine multiple services with each other. The CloudFrontToS3 construct, for example, connects a CloudFront distribution (CDN) with an S3 bucket. This is often used for hosting single-page applications.
Stacks bundle multiple Constructs together and build them into one deployable unit. The concept is similar to stacks in CloudFormation. One stack contains one or more Constructs.
Here is an example stack in CDK:
Modeling stacks is an art in itself. There are two common approaches to modeling your stacks:
In this example, we can see that DynamoDB is in the stateful stack. Lambda and API Gateway are in the stateless stack.
The second common approach is to model your stack by Microservices:
Whatever you decide, try to stick to one approach ๐
This brings us to the last concept, the App. The App is the entry point of your CDK application (hence the name). The CDK app combines all stacks.
The app bundles all stacks together and has several phases: constructing, validating, synthesizing, and deploying your infrastructure.
The details here are not important to get started with the CDK!
This is about the CDK introduction ๐
Now get your hands dirty with your first hands-on project.๐ฉโ๐ป ๐งโ๐ป
โ
Have a great rest of the week!
Sandro & Tobi โ๏ธ
โ
P.S.: Thanks for making it that far. Maybe you didn't know, but we are working on a new project: The CloudWatch Book. This project will include deployable code ๐พ, an e-book ๐, infographics ๐ธ, and even a video course ๐ฝ๏ธ.
![]() |
If you want to receive detailed info about this in the future, click on the following button โ
I want to know more about the CloudWatch Book ๐ |
๐ก As a subscriber, you can get our e-book with a 15% discount at all times.
Still hungry for AWS content? Have a look at our blog! ๐ โ
We teach AWS for the real world - not for certifications. Join more than 10,500 developers learning how to build real-world applications on AWS.
AWS FOR THE REAL WORLD โฑ๏ธ Reading time: 17 minutes ๐ฏ Main Learning: How to build a secure, scalable AWS landing zone using AWS Organizations, Service Control Policies, and Identity Center for centralized account and user management. ๐ Blog Post Hey Reader ๐๐ฝToday I want to dig into how to set up a proper AWS landing zone. Weโll be chatting about AWS Organizations, Service Control Policies (SCPs), and Identity Center. These are the core tools I reach for when I need to get accounts organized,...
AWS FOR THE REAL WORLD โฑ๏ธ Reading time: 15 minutes ๐ฏ Main Learning: How to build an automated related posts feature by leveraging Bedrock Knowledge Bases and Amazon S3 Vectors for content discovery. ๐ Blog Post Hey Reader ๐๐ฝEver wanted to show folks โrelated postsโ but didnโt want to build your own search from scratch? Weโve been playing with Bedrock Knowledgebases and S3 vectors, and turns out, it makes that job way easier than expected.Weโll go over how you can use these tools to connect...
AWS FOR THE REAL WORLD โฑ๏ธ Reading time: 8 minutes ๐ฏ Main Learning: How to automatically generate professional AWS architecture diagrams using Amazon Q with MCP servers ๐ Blog Post Hey Reader ๐๐ฝLetโs talk about saving money on AWS. Cost surprises are no funโespecially for folks just starting out. AWS pricing looks easy at first, but there are so many little things that can trip you up if youโre not careful.Today Iโm breaking down a few simple tips that actually work for beginners. Letโs jump...