AWS, Cloud Computing

4 Mins Read

How to Create Cloud Infrastructure using the AWS Cloud Development Kit

Introduction to CDK

The AWS CDK allows developers to define their cloud application resources using popular programming languages such as TypeScript, JavaScript, Python, Java, C#, and Go. It is an open-source software development framework that enables the coding of cloud infrastructure and its provisioning using AWS CloudFormation.

The CDK can be thought of as a cloud infrastructure compiler, providing a set of high-level class libraries, known as Constructs, that abstract cloud resources and encapsulate AWS best practices. These Constructs can be combined into object-oriented CDK applications that precisely define the application infrastructure, eliminating complex boilerplate logic. When the CDK application is run, it is compiled into a CloudFormation Template, which serves as the assembly language for AWS cloud infrastructure. The template is then processed by the CloudFormation provisioning engine and deployed into the user’s AWS account. The CDK tools simplify the process of defining the application infrastructure stack, while the CloudFormation service handles the secure and dependable provisioning of the stack.

Infrastructure management workflow with AWS CDK is shown below:

Workflow2

Source: AWS

CDK Code structure

To simplify the concept of AWS CDK is that it consists of three major building blocks that allow us to customize the provisioning of our infrastructure:

  1. Apps
  • Executable program
  • Used to render and deploy cfn templates
  1. Stacks
  • Deployable unit
  • Aware of region and account
  1. Constructs
  • Representations of AWS resources
  • Can form a hierarchical tree structure

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Benefits of AWS CDK

  • The AWS CDK offers several benefits, including easier cloud onboarding through the use of existing skills and tools, acceleration of the development process, customization and reusability of code, leverage of the full power of the programming language, and type-checking for the infrastructure.
  • The AWS CDK offers several benefits to developers including easier cloud onboarding, faster development processes, customizability and reusability, and the ability to leverage the full power of programming languages. It also provides type-checking for the infrastructure to avoid compiler errors.
  • The CDK can be used to improve infrastructure and business logic, a provision common infrastructure patterns faster, migrate complex backends more efficiently, and automate AWS service provisioning. Developers can also use constructs created by the community to programmatically create new microservices, and code applications using tools built for the cloud.

Use cases

AWS CDK include improving infrastructure and business logic, developing apps more efficiently, provisioning common infrastructure patterns, migrating complex backends, automating AWS service provisioning, using tools built for the cloud, and accelerating transitions from new to fully deployed infrastructure.

Demo to create S3 bucket using CDK

Pre-requisites

  • NPM
  • AWS CLI

Step 1: To create CDK, start by installing CDK

  • npm install -g aws-cdk
  • cdk version (to check if it’s installed)

Step 2: Initiate the CDK app with cdk init app –language python

Step2

Step 3: This gives us a default code as shown below

Step3

Step 4: Enter the following code

Step4

Step 5: Once your code is entered, deploy the CDK by cdk deploy

Step5

Step5b

Stack:

Step5c

Result:

Step5d

Step 6: Cleanup the resources by cdk destroy

Step6

Conclusion

AWS Cloud Development Kit is a code-first approach to defining cloud application infrastructure. From that launch, and following the “release early, release often” philosophy, more than 30 versions of it have been released to deliver new features as quickly as possible. As it continues to gain more traction, new features will be developed quickly and released often. The AWS CDK provides a powerful tool for developers to define their cloud infrastructure using familiar programming languages and provision it using the AWS CloudFormation service, making it easier and more efficient to develop and manage cloud applications.

The best practices and tools that are shared will keep our code and infrastructure quality high without sacrificing the speed of delivery.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding AWS CDK and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. How much does AWS CDK cost?

ANS: – No additional charge for AWS CDK. You will have to pay for AWS resources.

2. AWS SDK vs AWS CDK

ANS: – CDK is Infrastructure as Code, which means we can write code to create AWS resources like Lambda, DynamoDB, or API Gateway. Whereas SDK helps to interact with these AWS resources for ex: list the contents of S3 bucket or fetch the items from DynamoDB.

3. What is the relationship between AWS CDK and CloudFormation?

ANS: – Think of the AWS CDK as a developer-centric toolkit leveraging the power of modern programming languages to define our AWS infrastructure as code. When its applications are run, they compile down to fully formed CloudFormation JSON/YAML templates that are then submitted to the CloudFormation service for provisioning. Because the AWS CDK leverages CloudFormation, still has all the benefits CloudFormation provides such as safe deployment, automatic rollback, and drift detection.

WRITTEN BY Suresh Kumar Reddy

Yerraballi Suresh Kumar Reddy is working as a Research Associate - Data and AI/ML at CloudThat. He is a self-motivated and hard-working Cloud Data Science aspirant who is adept at using analytical tools for analyzing and extracting meaningful insights from data.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!