Enter CDK: What this Means for the World of IaC

Rate this content
Bookmark

CDK is growing in popularity in the AWS ecosystem, and is set to be the successor of CloudFormation, being built natively for the configuration of AWS resources. Learn how this is a game changer for NodeJS programmers & stacks.

FAQ

AWS CDK, or Cloud Development Kit, is a framework developed by AWS that allows developers to define their cloud infrastructure using familiar programming languages instead of configuration languages. It enables the creation of cloud resources using constructs which are higher-level components that pre-configure cloud resources with sensible defaults.

AWS CDK is considered a successor to CloudFormation, offering improvements such as the ability to use programming languages for defining infrastructure, which can simplify the creation and management of complex setups. CDK also supports multi-regional deployments more effectively than CloudFormation, which requires stack sets for similar functionality.

Yes, while AWS CDK is written in TypeScript and works best with it, it also supports other programming languages including JavaScript, Python, and Go, allowing developers to define infrastructure using the language they are most comfortable with.

Migrating from CloudFormation to AWS CDK can simplify infrastructure management by reducing the complexity and size of configuration files, improving readability and maintainability. CDK also allows for easier handling of multi-regional deployments and offers a more intuitive approach by using familiar programming constructs.

AWS CDK is suitable for developers, DevOps, and SRE teams who are already using AWS and prefer to use code for infrastructure management. It is especially beneficial for users looking to migrate from CloudFormation, as it simplifies and enhances the infrastructure as code practices.

AWS CDK simplifies multi-regional deployments by allowing developers to define multiple stacks within their code, which can then be deployed to different regions directly without the need for additional tools like AWS Stack Sets, which are required when using CloudFormation.

Migrating from CloudFormation to AWS CDK involves creating equivalent CDK constructs for existing CloudFormation templates and then deploying these constructs using CDK commands. The process is streamlined due to the similar underlying mechanisms between CloudFormation and CDK.

No, AWS CDK is specifically designed for managing AWS resources and does not natively support other cloud providers. For multi-cloud environments, tools like Terraform or Pulumi might be more appropriate.

Key advantages of using AWS CDK include the ability to use general-purpose programming languages, simplified multi-regional deployments, improved code reusability, and a more intuitive approach to infrastructure as code that leverages familiar coding practices.

Roy Tal
Roy Tal
13 min
24 Mar, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

AWS CDK is a concept that allows you to use coding languages to create infrastructure as code, making it more flexible and powerful than traditional config languages. CDK offers benefits such as improved developer experience, multi-regional deployments, and a programmatic approach to infrastructure as code. It is a suitable choice for AWS users, particularly those familiar with CloudFormation. CDK can be used to migrate from CloudFormation to a more efficient and user-friendly infrastructure management tool. CDK also provides drift detection and supports multi-region deployment, making it a popular choice for managing infrastructure on AWS.

1. Introduction to AWS CDK

Short description:

I'm going to talk to you about AWS CDK and what does it mean for the world of infrastructure as code using AWS CDK. CDK aka Cloud Development Kit is a concept not only by Amazon also by Kubernetes and also by Terraform themselves. CDK means that you're not using any config language to create your infrastructure as code such as the JSONs, HCLs and even YAMLs but you're using coding languages in the AWS CDK, they now support TypeScript of course and JavaScript.

Hey everyone, I'm Roy and today I'm going to talk to you about AWS CDK and what does it mean for the world of infrastructure as code using AWS CDK. Today I'm an engineering team leader at Firefly and what we do at Firefly is to take your entire cloud footprint along with your Kubernetes clusters infrastructure and on the other end to take your infrastructures code if it's CDK or even Terraform, Pulumi, CloudFormation and even Helm and to combine them and to show you a merged inventory that shows your entire cloud asset footprint in the means of your infrastructure as code.

Also as you can see I like Schnitzel call of duty and infrastructure as code, I guess the same as all of you. What is actually CDK and what is the huge hype about CDK so when I was visiting the last AWS event I couldn't stop noticing that everyone is asking about CDK. They asked how to start working with CDK and in what languages they wanted to know how they migrate their own CloudFormation stacks into CDK and I think that with all these questions I started investigating as part of what we do at Firefly which is to use the best infrastructure as code and to supply our customers the best infrastructure as code and after a quick run over CDK I discovered an amazing new tool by AWS that you must be familiar with and an even easier way to migrate your CloudFormation into CDK so what is actually CDK?

CDK aka Cloud Development Kit is a concept not only by Amazon also by Kubernetes and also by Terraform themselves. CDK means that you're not using any config language to create your infrastructure as code such as the JSONs, HCLs and even YAMLs but you're using coding languages in the AWS CDK, they now support TypeScript of course and JavaScript. TypeScript by the way is the language that it was written in so it works best in TypeScript but also JavaScript Python and even Golang. Besides CDK is the CloudFormation successor. CDK is the brand-new fully-oriented AWS tool to create resources with and it's much better than CloudFormation.

2. Benefits and Usage of CDK

Short description:

CloudFormation is messy and not so likeable to work with, but CDK solves these issues by using classes and variables to create resources. CDK also supports multi-regional deployments, allowing you to create multiple stacks and deploy them to different regions. CDK is the native experience for AWS and supports multiple languages. It turns code into cloud formation stacks, which can be deployed using CDK deploy. CDK is suitable for anyone using AWS, especially CloudFormation users looking to migrate their stacks. It's also beneficial for DevOps, SRE teams, and developers who want a more programmatic approach to infrastructure as code.

In let's say three major points. The first one is that CloudFormation is messy. If you're gonna write lots of resources because of its super explicit way of approach even CloudFormation is going to be a super huge YAML or JSON. Depends on your benefit but it's gonna if you have much resources, it's going to be a heavy file and not so likeable to work with.

Also, if you're gonna create relations in your CloudFormation it's going to be a hell because it's making it super messy super buggy and not even understandable for anyone that doesn't know it. CDK solves all of these notes because CDK uses classes and variables such as any other coding language to create the resources with it.

Also another major point is the multi-regional way of working with CloudFormation. As you already know, CloudFormation does not support multi-regional and if you want to deploy your CloudFormation stack in some, in multiple regions, you'll need to use stack set, a kind of patch that AWS wrote to deploy one CloudFormation stack in multiple regions. With CDK it's basically solved because CDK supports the stack out of the code. You can create as much stacks as you can inside your code and just deploy them one by one into each region you wish.

Also, CDK is basically now the native experience of AWS, which means that it's not only 100% AWS-orient, it's the only way to, the only way, the only thing you can write with CDK is basically AWS, so it's not fit to any other providers, it's full AWS service so it means it works best with AWS and only AWS. Even more than this, as I already said, CDK supports multiple languages. The most typical one is TypeScript but you can write also JavaScript and much more languages with it, which is amazing because basically, if you think about it, you can write one repo, put in this repo your already existing coding or programming functions. On the other hand, you can put in the same repo your infrastructure as code, such as in CDK, and then if you, let's say, deploy an instance with some code, you can define the instance itself in the same repo, which is basically a branding amazing way to work with infrastructure as code.

So, how does CDK work? CDK turns code into cloud formation stacks, which basically means that AWS wrote CDK on top of the old cloud formation mechanism. You're going to write it in each language you wish, as we already described, and you're going to write constructs, which means creating an S3 bucket resource or a instance resource, for example. After writing this in these resources, you're going to use the command CDK synth, which is basically a dry run of what you already wrote, and it will generate automatically the cloud formation template that describes exactly the resources you wrote in any other coding language you used. So, creating the CDK synth created a template, and then following that, you're going to use CDK deploy to deploy the stacks by actually creating cloud formation stacks with this template inside, and creating out of the stacks the resources on your AWS specified region or regions, for example.

Deploying will create two artifacts, one, an S3 bucket files that run the state, let's say, of your CDK code. It saves the resources that were created, the changes that it made, and you can track over there and see the state of the lately deployed stack. Beside, it's going to create the CloudFormation stack itself, which creates the resources out of it. Into your cloud.

So who should use CDK and when? It's a pretty typical question because the who is basically everyone, everyone that uses AWS because CDK is the 100% oriental way to approach, let's say, to create infrastructure as code over Amazon. And especially CloudFormation users that wish to migrate the CloudFormation old stacks into CDK. It's gonna be a pretty easy process to go through and we'll do it in the example following that. Another group is like any DevOps or SRE teams that are working with AWS. And besides, if you can think about it, even your developers can use CDK because now it's not a knowledge you need to experience with YAMLs or config. It's just coding, the same as any other programmatic coding you do. And besides, all of the infrastructure code users who work over AWS, it's best to work with CDK.

When? When is, I think, every time because if you're already using any infrastructure as code, it's always a good way and always a good time to start working with a tool that is officially working with AWS.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Levelling up Monorepos with npm Workspaces
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Levelling up Monorepos with npm Workspaces
Top Content
Learn more about how to leverage the default features of npm workspaces to help you manage your monorepo project while also checking out some of the new npm cli features.
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Automating All the Code & Testing Things with GitHub Actions
React Advanced Conference 2021React Advanced Conference 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
Code tasks like linting and testing are critical pieces of a developer’s workflow that help keep us sane like preventing syntax or style issues and hardening our core business logic. We’ll talk about how we can use GitHub Actions to automate these tasks and help keep our projects running smoothly.
Fine-tuning DevOps for People over Perfection
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
Demand for DevOps has increased in recent years as more organizations adopt cloud native technologies. Complexity has also increased and a "zero to hero" mentality leaves many people chasing perfection and FOMO. This session focusses instead on why maybe we shouldn't adopt a technology practice and how sometimes teams can achieve the same results prioritizing people over ops automation & controls. Let's look at amounts of and fine-tuning everything as code, pull requests, DevSecOps, Monitoring and more to prioritize developer well-being over optimization perfection. It can be a valid decision to deploy less and sleep better. And finally we'll examine how manual practice and discipline can be the key to superb products and experiences.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
You can check the slides for James' talk here.
ESM Loaders: Enhancing Module Loading in Node.js
JSNation 2023JSNation 2023
22 min
ESM Loaders: Enhancing Module Loading in Node.js
Native ESM support for Node.js was a chance for the Node.js project to release official support for enhancing the module loading experience, to enable use cases such as on the fly transpilation, module stubbing, support for loading modules from HTTP, and monitoring.
While CommonJS has support for all this, it was never officially supported and was done by hacking into the Node.js runtime code. ESM has fixed all this. We will look at the architecture of ESM loading in Node.js, and discuss the loader API that supports enhancing it. We will also look into advanced features such as loader chaining and off thread execution.

Workshops on related topic

Node.js Masterclass
Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Matteo Collina
Matteo Collina
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
0 to Auth in an Hour Using NodeJS SDK
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
Deploying React Native Apps in the Cloud
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Cecelia Martinez
Cecelia Martinez
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.