AWS, Cloud Computing

4 Mins Read

How to Create Cloud Infrastructure using the AWS Cloud Development Kit

Voiced by Amazon Polly

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

Freedom Month Sale — Upgrade Your Skills, Save Big!

  • Up to 80% OFF AWS Courses
  • Up to 30% OFF Microsoft Certs
Act Fast!

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

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.

Freedom Month Sale — Discounts That Set You Free!

  • Up to 80% OFF AWS Courses
  • Up to 30% OFF Microsoft Certs
Act Fast!

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

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!