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

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

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.

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 a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFront Service Delivery PartnerAmazon OpenSearch Service Delivery PartnerAWS DMS Service Delivery PartnerAWS Systems Manager Service Delivery PartnerAmazon RDS Service Delivery PartnerAWS CloudFormation Service Delivery PartnerAWS ConfigAmazon EMR and many more.

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!