Conf42 Cloud Native 2022 - Online

Go CDK! What this Means for the World of IaC

Video size:

Abstract

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.

CloudFormation that had its own set of limitations, opened the door for the widely adopted existing infrastructure as code tools we have all grown to love - including Terraform and Pulumi.

In this talk, we’ll dive into why CDK is a game changer for AWS-based deployments. How it works with your existing developer flows and favorite programming languages - from NodeJS to Golang and even Python, and brings the inherent benefits from using your programming language of choice. We’ll also dive into what the migration looks like from your existing IaC tools - whether CloudFormation, Terraform or Pulumi, when others tools are a better for fit for your use case, and will wrap up with code samples based on CDK and Golang.

Summary

  • The AWS CDK is the successor of cloud formation in AWS. It uses the cloudformation stacks to deploy your code into the AWS resources. All cloudformation users should use CDK because it's super easy to migrate into. Any other enthusiast of infrastructure can start working with CDK.
  • AWS CDK supports multiple languages if it's typescript. It doesn't require any DSL or config such as JSon or YAMls. You can create complex yak projects with it. Also lastly, it's AWS oriented. It's going to be the best experience on AWS cloud if you're going to do infrastructure as code at all.
  • Roy: CDK is a rising technology. I recommend you to use the CDK now instead of later on. Migrate your project and make your life much better when using AWS, CDK and the other one. I'd like to keep in touch for any questions you have.

Transcript

This transcript was autogenerated. To make changes, submit a PR.
Hey everyone, I'm Roy, team leader at Firefly. And today I'm going to talk to you about the AWS CDK and what does it mean for the world of infrastructure as code? So as I said, as a team leader in Firefly, what we do is basically look at your entire cloud footprint, or kubernetes clusters. We fetch them into our console and we show you on the other end your entire infrastructure as code footprint, whether it's terraform, Pulumi, cloudformation, CDK of course, and even helm. In the world of kubernetes, we track them both together and we show your entire cloud footprint in the means of your infrastructure as code. We can detect drift in real time and we can help you codify them back to infrastructure as code in any language you can think of. AWS part of me working at Firefly. As you can see, I'm very enthusiastic about Yak. And when I was in the last reinvent, I saw a huge hype about the CDk tool of AWS and got into it a bit. So basically at reinvent, all of the guys coming into our boot estate about the AWS CDK and how can they use it and how do they start even using CDK instead of cloudformation or even any other infrastructure AWS code you can think of. I started searching about it and saw that CDK is basically a very cool tool that AWS brought us, and we can migrate our cloudformation very quickly into CDK and even start new projects in CDK in a heartbeat. So as you can see, CDK is basically more of a concept than an AWS tool. It means cloud development kit and this means that each infrastructure code tool that is written in code, whether it's Python, go typescript and even node JS, and not written in configuration language such as Yaml's, JSON and etc, is a cloud development kit. The AWS CDK is an implementation of AWS to this concept and is going to be the successor of cloud formation in AWS. They created it originally and native to the AWS experience. So using the AWS CDK is a very comfortable experience when you're deployments into AWS resources. Also, you can use any coding language you can think of, whether it's typescript, which is originally created in, or Golden Python node JS and moro tools are on the way. So how does AWS CDK works and what is it different from the cloud formation? So as you can see, CDK is basically written over the cloud formation and it uses the cloudformation stacks to deploy your code into the AWS resources. Basically, you can use any language you can think of, as we already said, and then you create constructs, you create your AWS resources in code. You can create any resource of AWS that you were able to create with cloudformation through the CDK code. And after creating the CDK project, let's call it, you can just create CDK, synth and deploy. And you create your resources on your AWS cloud through cloud formation stacks, as you can see in the map over here. So first of all, you do the CDk sync command. It's basically planning your code into state file that is going to be created on your cloud. And after running the command CDk deploy the command, will create the resources on your cloud, will save the state file on s three bucket on your cloud, and also create the cloudformation stacks that was deploying your resources on the cloud. If that's the case, then who should use CDK and when? So basically, first of all, all cloudformation users should use CDK. Why? Because it's super easy to migrate into CDK. It's natively AWS such as cloudformation, and it's also super comfortable to work in. If you're even working with Stackset or deploying into multi regions, Cloudformation won't be able to do it. And you'll need to use Stackset, which is like patch over cloudformation, to create stacks in multiple regions. In CDK, it's natively written because it's just code, and you can create models to deploy in each region out of the stack that you already created in CDK. Even more than that, AWS oriented DevOps and SRE teams will be much like to use the CDK, even if they're not using cloudformation at the moment. Doing it with any other languages such as terraform or even Pulumi. Moving to CDK is going to be a native experience for AWS users, so it's also a good idea to work with. And lastly, any other enthusiast of infrastructure AWS code can start working with CDK, create some projects and see if it's fun to play with. I guarantee a very good experience out of it when. So if you're already using any cloudformation projects, then you should use CDK right away. As I said, super easy migration and you can just start playing with CDK. Do it much easier than creating the messy yamls or JSons of Cloudformation, and you'll see the difference right away. Another time to start is if you start a new infrastructure called Project and you think about the tool to work with, if it's going to be on AWS, then it's sure to have with CDK. So let's talk a bit about the pros and cons of AWS CDK. So as I said, the pros are pretty much straightforward. It supports multiple languages if it's typescript that it's originally created in JavaScript, Python, Java Net and even Golang. Also, it doesn't require any DSL or config such as JSon or YAMls. You can create complex yak projects with it. As you know, cloud formation is super messy code to write, and if you're going to create a big project, it's going to be a hell. The dependencies are going to be huge, and if you're creating links between assets, it's not going to work or it's going to be a hell for you to maintain and develop. Also, as I said, the multi region operations, you don't need to use taxit, you can just create any models you wish and you'll do it on any region you want. And also lastly, it's AWS oriented. So basically it's going to be the best experience on AWS cloud if you're going to do infrastructure as code at all. Also, if you're using any other CDK, as I said, if the concept is not AWS invention such as CDK for terraform or CDK for kubernetes, then other CDK is going to match better for you and not the AWS one. So let's see some code. As you can see here, I have two files. One defines a CDK stack, creates an S three bucket and an SQS queue out of a new resources that you can see on your code. And the last resource is a cloud formation import. I basically already have a cloud formation as you can see on the others window that defines an EC two instance. And by migrating all the AML of the cloud formation into this stack, I will basically have the CDK in this CDK stack. And in heartbeat I just imported the entire cloudformation into CDK and it's just easy as that. You can take huge examples of yamls or JSON's cloudformation, you can just import them into CDK and in heartbeat you will be migrated and you can just keep on working with CDK instead of cloudformation, which is basically amazing. Also, as you can see here, after clicking synth and deploy, I deployed my CDK stack into AWS through a cloud formation stack. I also have my state files in an S three bucket and these two stacks were created out of the deploy. The first one, the CDK toolkit, is code stack that is creating the necessary resources on your AWS, such as the bucket the state file is going to be saved in. And the other stack here is my CDK deploy that I ran and as you can see, I created a bucket, an SQS, and also the migrated cloud formation which is now supported in my new CDK stack and AWS. You can see it's defining an EC two instance straight out of my CDK call, even though it was created on Cloudformation, which is amazing. So this was my lecture, and now I want to talk to you about two important key takeaways that I wish to pass on. So the first one, CDK, is a rising technology. It's still in its few first steps, and it's probably going to get much bigger in the next few months. I absolutely recommend you to use the CDK now instead of later on. Migrate your project and make your life much better when using AWS, CDK and the other one. If you're a cloudformation user, then you're even more recommended to go into CDK and start working with it and you'll see the magic happens in few minor steps. Thank you everyone with Roy. I'd like to keep in touch for any questions you have. You can see my mail here. So thank you so much and have an amazing day.
...

Roy Tal

Engineering Team Lead @ Firefly

Roy Tal's LinkedIn account Roy Tal's twitter account



Awesome tech events for

Priority access to all content

Video hallway track

Community chat

Exclusive promotions and giveaways