Table of contents
1.
Introduction
2.
What is AWS CDK?
2.1.
Terminal
2.2.
Building Blocks of AWS CDK
2.3.
AWS CDK Construct Concept
2.4.
Features of AWS CDK
2.5.
Good AWS CDK Usage Practices
2.6.
Developer Tools for AWS CDK
3.
Frequently Asked Questions
3.1.
What is AWS?
3.2.
What is AWS CDK?
3.3.
What are the building blocks of AWS CDK?
3.4.
What are the different construct concepts in AWS CDK?
4.
Conclusion
Last Updated: Mar 27, 2024
Medium

AWS CDK

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

In today’s world, every business is going online. And every business is using a cloud environment nowadays. Being on the cloud has various benefits, including storage, computation power, database, serverless computation, etc. And when we talk about cloud computing, AWS(Amazon Web Services) is the first to come to mind.

AWS CDK

In this article, we will study AWS CDK.

What is AWS CDK?

AWS CDK stands for Amazon Web Services Cloud Development Kit. It is a framework for defining and providing Cloud infrastructure through code and deploying it.It is an open-source project. So, the community can code and update some things in it and directly pass the feedback to the authorities. It supports various languages like TypeScript, JavaScript, Python, Java, C#, and Go.

To start with AWS CDK, you can install the AWS CDK on your system using the node package manager.

You can use the following command to achieve it.

  • Terminal

Terminal

npm install -g aws-cdk

 

OUTPUT

installing aws cdk package

Building Blocks of AWS CDK

Let us look at the three building blocks of AWS CDK. These are app, stack, and construct.

AWS CDK core concept
  • App:- This is the root of the construct tree. It is responsible for consolidating stacks and the constructs in one application, which is further used to deploy on the AWS cloud.
     
  • Stack:- It is the unit that holds the AWS resources in the form of constructs that are used for deployment.
     
  • Construct:- It is a culmination that can hold a single AWS resource or a combination of multiple resources. Users can build or combine AWS resources in their constructs themselves.

AWS CDK Construct Concept

There are multiple constructs in stacks. Each construct has different AWS resources. In terms of benefits, constructs are a great deal in AWS CDK. And there are three ways to build constructs in AWS CDK. Each way has its own features.

  • L1 Constructs:- These constructs are the AWS Cloudformation resource types inculcated in AWS CDK. Their properties are just the same as in AWS Cloudformation. If a developer can build L2 and L3 constructs, there is no real benefit in using L1 Constructs. But, if an L2 or L3 construct cannot customize some property in API, an escape hatch is used.
     
  • L2 Constructs:- These constructs are AWS resources built by the AWS CDK team consisting of L1 construct functionalities and sensible defaults. You can create AWS resources with only a few lines of code using these.
     
  • L3 Constructs:-  These are patterns. These are mainly a group of L2 constructs to deliver total solutions. You can culminate multiple resources like an Application Load Balancer and an E2C instance. You can build these with a few lines of code and resume them to your requirements.

Features of AWS CDK

Now that we have seen the building blocks and construct types of AWS CDK let us study some essential features of it.

  • It supports multiple languages like JavaScript, Python, etc.
     
  • Users can use their own development tools to enhance the code quality of the AWS CDK project.
     
  • It provides a construct hub. So, the users do not have to create their own L2 or L3 constructs every time. They can extract them from the hub, whichever fulfills their requirements.
     
  • The infrastructure, application, configuration, and deployment are all under a single repository of one AWS CDK application.
     
  • Since it is open source, it can provide feedback to the developer team.
     
  • It can generate thousands of CloudFormation templates with only a few lines of code in TypeScript.
     
  • It can generate recursive functions to generate various AWS resources.

 

Thus, we can see that AWS CDK is preferred due to its features which make it beneficial for usage.

Good AWS CDK Usage Practices

Let us look at some good AWS CDK usage practices for efficient development.

  • You should create multiple stages of your project, like designing, development, testing, etc., so that you can build changes from your AWS CDK application.
     
  • You can add automated integration tests to mitigate any breaking changes.
     
  • You should use the “cdk diff” command to see the changes before deployment.
     
  • Create safe constructs for usage. Also, you should free your space by deleting multiple copies of useless stacks.

Developer Tools for AWS CDK

For faster deployment and good-quality of code, developers should use good development tools for AWS CDK projects. Some of them are discussed below:-

  • Projen:- It is a project generator that helps initialize new AWS CDK projects. It helps you to synthesize config files from a definition written in TypeScript.
     
  • AWS Toolkit for VS Code:- It helps users to gain a tree view on your AWS CDK application.
     
  • Eslint:- It helps in statistical code analysis to find and resolve problems.
     
  • CDK-nag:- It checks the application based on the library rules. It helps in enforcing high-standard regulations for your application.

Frequently Asked Questions

What is AWS?

AWS stands for Amazon Web Services. It provides companies, governments, and even individuals with cloud computing platforms and APIs. The payment method is on a pay-as-you-go basis. Currently, it is the world’s most comprehensive cloud service.

What is AWS CDK?

AWS CDK stands for Amazon Web Services Cloud Development Kit. It is a framework for defining and providing Cloud infrastructure through code and deploying it. It is an open-source project. So, the community can code and update some things in it and directly pass the feedback to the authorities.

What are the building blocks of AWS CDK?

The three building blocks of AWS CDK are app, stack, and construct. These three, together, make up the AWS CDK project. The app is the root of the constructed tree. Stack stores AWS resources, and AWS resources are built under constructs.

What are the different construct concepts in AWS CDK?

The three different construct concepts in AWS CDK are the L1 construct, the L2 construct, and the L3 construct. L1 construct is the AWS CDK version of the CloudFormation AWS resources build. The L2 and L3 constructs are more beneficial than L1.

Conclusion

Today, being on the cloud is essential for the project's growth. Whether it is an individual’s project or a business one, being on the cloud is beneficial in every scenario. In this article, we studied AWS CDK(Amazon Web Services Cloud Development Kit). We looked at its building blocks, features, construct types, development tools, and good usage practices.

If you want to learn more about this subject, read the following articles:-

 

To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Codestudio. Also, you can enroll in our courses and check out the mock test and problems available. Please check out our interview experiences and interview bundle for placement preparations.

 

Happy Coding!

Live masterclass