SKD-VS-CDK.png

AWS CDK vs AWS SDK

Last Updated | Dec, 20, 2022 By Kingsley Ijomah
AWS SDK is a set of tools for building software applications that use AWS services, while AWS CDK is a framework for defining and provisioning cloud infrastructure.

AWS CDK (Cloud Development Kit) is an open-source software development framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation. It allows developers to use familiar programming languages and deploy cloud applications using AWS resources.

AWS SDK (Software Development Kit) is a collection of tools that enables developers to build software applications that make use of AWS services. It provides APIs (Application Programming Interfaces) for a variety of programming languages, allowing developers to integrate AWS functionality into their applications.

In summary, AWS CDK is a framework for defining and provisioning cloud infrastructure, while AWS SDK is a set of tools for building software applications that use AWS services. You can use both CDK and SDK together to build cloud applications on AWS.

Here are some code examples to show the difference between using AWS CDK and AWS SDK to perform similar tasks.

Using AWS CDK to create an Amazon S3 bucket:

code
import * as cdk from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';

class MyStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new s3.Bucket(this, 'MyBucket', {
      bucketName: 'my-bucket-name',
      versioned: true,
      publicReadAccess: false
    });
  }
}

Using AWS SDK for JavaScript to create an Amazon S3 bucket:

code
const AWS = require('aws-sdk');

// Set the region
AWS.config.update({region: 'REGION'});

// Create S3 service object
const s3 = new AWS.S3({apiVersion: '2006-03-01'});

const bucketParams = {
   Bucket: 'my-bucket-name',
   CreateBucketConfiguration: {
      LocationConstraint: 'REGION'
   }
};

// Create the bucket
s3.createBucket(bucketParams, function(err, data) {
   if (err) {
      console.log("Error", err);
   } else {
      console.log("Success", data.Location);
   }
});

As you can see, AWS CDK provides a higher-level interface for defining and provisioning cloud resources, while AWS SDK provides more granular control over the individual API calls being made to the AWS services.

MY STORY

My name is Kingsley Ijomah, I am the founder of CODEHANCE, an online education platform built with you in mind, a place where I express my gratitude to a skill ( coding ) which has changed my life completely.

Learn To Code With Me.
FREE course included.

GET IN TOUCH

Enter your email address:

Delivered by FeedBurner