DEV Community

Cover image for AWS CDK First impression
Yeison Cruz
Yeison Cruz

Posted on

AWS CDK First impression

On July 2019 was released the AWS CDK a code-first library to define cloud application infrastructure.

The AWS CDK is a new software development framework from AWS with the sole purpose of making it fun and easy to define cloud infrastructure in your favorite programming language and deploy it using AWS CloudFormation.

The first thing that i realized is the AWS Cloudformation compatibility. every new written code is transformed to YML template, so almost everything in Cloudformation can be used here and that is really util.

There is really big advantage, and is the way you can create the application infrastructure, now you can use different languages as JavaScript, Python, Java, C# and also Typescript. And this is a really good feature because sometimes developers are not familiarized with YAML structure's and JSON is not the best way to create a Cloudformation template, so now you will choose your preferred language and just start to create the needed resources using the library.

And now as the resources are created using code, you can create unit test to improve the quality and make sure a new developer is no going to change something important there.

With CloudFormation, you also can write some tests, but it requires another tool

Ok, now let's talk about constructors, is a new introduced concept and are so useful because now you won't need to create a lot of unnecessary as you usually do in YAML, just "WRITE LESS AND DO MORE", for example We need to write around 1000 lines of code using CloudFormation, when we try with AWS CDK, we only need to write around 50 lines of code.

// DynamoDB table constructor
new Table(scope: Construct, id: string, props: TableProps);

// This represents a single EC2 instance.
new Instance(scope: Construct, id: string, props: InstanceProps)

// Creates a new EBS Volume in AWS EC2
new Volume(scope: Construct, id: string, props: VolumeProps)
Enter fullscreen mode Exit fullscreen mode

CDK vs YAML
yaml-vs-code


More good things, the deployment process is a little bit friendly and request some confirmations before deploy.

yaml-vs-code

Also you can see the updated resources easily after deploy.

yaml-vs-code

There is something that personally is bad, and is the way to run the application locally. You can't do it using AWS CDK, you have to build the code to YML and execute it using AWS SAM, so you will need and step more before try every new change locally.


I hope this post has been useful for you.

Finally, you have a great Workshop here: https://cdkworkshop.com/

CDK use guide: https://docs.aws.amazon.com/cdk/latest/guide/home.html

Some examples: https://github.com/aws-samples/aws-cdk-examples

Top comments (2)

Collapse
 
vekmaster profile image
Kevin D. Agudelo Gallego

Excellent, It's a wonderful way to build your infrastructure taking advantage from all Programming language features

Collapse
 
loujaybee profile image
Lou (🚀 Open Up The Cloud ☁️)

This is nice, I've been meaning to look into the CDK more, I hear constantly good things, thanks for writing!