Tutorial Highlights & Transcript

  • 00:07 - What is AWS CDK?

    • Randy Newell 00:07

      Welcome to nSights, tech talks with nClouds. I'm Randy Newell. And I'm here with Marius Ducea. Marius, tell us, what is AWS CDK?

      Marius Ducea 00:21

      So AWS CDK, or the Cloud Development Kit, is an open source development framework, introduced by AWS in 2018. And it is designed to define the infrastructure as a code with modern programming languages. And it is actually deploying for CloudFormation. So frankly put, this is like AWS's answer to Terraform - it's its own TerraForm version, because honestly, it was losing ground in CloudFormation with TerraForm. And this was its answer. So instead of building something else, AWS built an abstraction on top of CloudFormation and allows us to use programming languages to define the infrastructure. So many infrastructure as code solutions take the form of configuration files, just like CloudFormation, or a custom domain language specific language like TerraForm with HCl. The CDK allows us to use native programming languages, like for example, TypeScript, C#, Java, Python, and so on. And this has become very successful. And other projects, which are not AWS related, appeared to add similar kind of functionality for TerraForm. Funny, which is called CDKTF, and also to Kubernetes, which is called CDK Kubernetes. And this allows people to define in Python or TypeScript or JavaScript construct, and behind the scene, build TerraForm or native Kubernetes services, which is pretty cool.

  • 02:10 - How does AWS CDK work?

    • Randy Newell 02:10

      It does sound cool. So how does AWS CDK actually work?

      Marius Ducea 02:16

      Yeah, yeah, so AWS CDK is a framework and you create a project, the CDK project, and when it is executed, it actually generates CloudFormation templates. So the project can be executed from the command line, or in a CI/CD pipeline, but it generates the CloudFormation templates. And these are either JSON and YAML, what you would expect from the CloudFormation. And if you want to, you can actually use these outside of CDK and just run them as regular CloudFormation templates. But most of the time, people will use the CDK CLI, because it has lots of advantages. And one of the main advantages is that you can do diffs and you can plan your deploys. So, actually at its core, CDK introduces a few concepts which are important and one of them is the constructs and the other one is stacks. So there are two types of constructs - the low level and the high level. The low level actually maps on one to one of CloudFormation resources and properties. So these will have a CFN prefix. And you can work with them just like the CloudFormation instead of JSON or YAML, you just define them in your programming language in Python or JavaScript. So, you have access to all the parameters and all the variables which you can pass to the CloudFormation resource. And higher level constructs on the other side are CloudFormation resources, which are bundled with some same defaults and provide a higher level interface. So for example, you can create a VPC higher level construct, and Amazon provides many of these out of the box available in CDK. And this will create like a NAT gateway in each availability zone, it will create different kinds of networks and so forth, you know, so these are all like you just put like a single line of code, and it just builds this automatically, which is super cool. And the other type of concept is stacks. So the stack is the basic unit of deployment in CDK. And this, you know, feels very natural with CloudFormation. It maps directly to a CloudFormation and the stacks are composable. So, someone can, you know, use just one stack in a CDK project, or they can have multiple stacks. They can, you know, have as many as they need it. Stacks can also share values. So one stack can consume resources from another stack. And behind the scenes, CDK just uses the CloudFormation import value to pass around different CloudFormation stacks.

  • 05:16 - Why use AWS CDK? What are the advantages?

    • Randy Newell 05:16

      Great, it sounds like there's some real flexibility there. Can you tell us a few more advantages? Why would someone want to use AWS CDK?

      Marius Ducea 05:25

      Yeah, absolutely. So there are many options for people to use infrastructure as code and us at nClouds, we implement and deploy for customers solutions based on CloudFormation, Terraform, Pulumi and CDK. So there's good tooling around infrastructure as code these days. But CDK brought to the market some really nice advantages. So first of all, it was the first one which is true infrastructure as code. So it leverages the full power of the programming language, such as conditional loops, string interpolation, and so forth. So for example, if the team which is working on this has already a strong development background, and let's say they use Python, they can literally put their infrastructure definition in the same kind of code and have it very natural for them, which is great that they don't have to learn something new. Also, one of the advantages is that CDK performs type checking for the infrastructure. So basically, each of the properties or parameters have explicit types. So these would result in compiler errors if you don't pass the correct information. So you don't have to learn the hard way that this is not really working, once you push it to deployment. And let's say if someone really likes using CloudFormation, this is a superior level of CloudFormation. So it combines many of the advantages of CloudFormation, because it builds natively CloudFormation, but it also brings in different advantages, which are not in CloudFormation. Like, for example, you can do a diff, like you can do CDK diff, and this will show you line by line, what are the differences and what is going to happen before pushing it to AWS, which is amazing. Something which TerraForm has, and it's very valuable for people to give confidence before pushing changes. CDK brings the same kind of functionality into CloudFormation. And there are a few others. But these would be the key advantages if your team has a development development background, then they would really love to have the same kind of thing, type checking, and also like really great integration and advantages on CloudFormation. And also, I will add one more thing, because of the popularity of the CDK typing, even the TerraForm has now the CDKTF project, which basically allows you to write in a similar kind of pattern, like in Python or JavaScript, TerraForm code, and at the at the back end, this will provision it as a TerraForm. This again, is a separate project, is not related to AWS, and actually right now it's a HashiCorp supported project. It was a community one, but it just shows the interest of people to do this in a higher level programming language.

      Randy Newell 08:38

      Fantastic! Well, Marius, thanks for spinning us up on AWS CDK. And thank you, everybody for viewing nSights, tech talks with nClouds. Till next time, thank you

Randy Newell

Randy Newell

CMO & Business Development


Randy joined nClouds in 2017 because he wanted to be part of an enormously talented team that is filling a real market need – helping growth companies innovate faster by using a DevOps and cloud approach to modern infrastructure. An early DevOps advocate, he co-launched and led worldwide marketing for DevOps at IBM, and had prior marketing and business development leadership roles at startups and global brands including DataEase, NeuVis, Rational, and PwC’s technology industry group.

marius ducea

Marius Ducea

VP, DevOps Practice


As the VP of DevOps Practice at nClouds, Marius leads the DevOps practice to launch existing and future solutions and products, help position nClouds as a recognized thought leader in the DevOps space, and help the DevOps engineers grow and get better every day. Before joining nClouds, Marius founded and ran a DevOps consulting company, Opscale. He worked with various San Francisco Bay Area startups (big and small) to solve infrastructure automation challenges.

Contact Us Now

You can also email us directly at sales@nclouds.com for your inquiries or use the form below

Subscribe to Our Newsletter

Join our community of DevOps enthusiasts. Get free tips, advice, and insights from our industry-leading team of AWS experts.