11

I am new to AWS with python. I came across boto3 initially, later somone suggested cdk. What is the difference between aws cdk and boto3?

Neha S
  • 137
  • 1
  • 6

4 Answers4

9

In simple terms, CDK helps you to programmatically create AWS resources(Infrastructure as Code) while boto3 helps you to programmatically access AWS services.

Here is a snippet on CDK and Boto3 from AWS reference links :

CDK:
The AWS Cloud Development Kit (AWS CDK) is an open source software development framework to define your cloud application resources using familiar programming languages. AWS CDK provisions your resources in a safe, repeatable manner through AWS CloudFormation. It also enables you to compose and share your own custom constructs that incorporate your organization's requirements, helping you start new projects faster. (Reference: https://aws.amazon.com/cdk/)

With CDK and Cloudformation, you will get the benefits of repeatable deployment, easy rollback, and drift detection. (Reference: https://aws.amazon.com/cdk/features/)

Boto3:
Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2. (Reference: https://pypi.org/project/boto3/)

Shree
  • 798
  • 5
  • 13
4

Welcome to Stack Overflow and to AWS usage!

boto3 is the python SDK for AWS. It is useful in order for your software to be able to elevate other AWS services.

use case example: your code has to put an object in an S3 bucket (store a file in other words).

aws-cdk is a framework that helps you provision infrastructure in an IaC (Infrastructure as Code) manner.

use case example: describe and provision your application infrastructure (e.g. a lambda function and an S3 bucket).

In many projects you will use both.

you can find an example URL shortener that uses boto3 and aws-cdk here. The URL shortener uses boto3 in order to access a DynamoDB table and aws-cdk in order to provision the whole infrastructure (including the lambda function which uses boto3).

Pistazie
  • 218
  • 2
  • 6
1

You're creating an application that needs to use AWS services and resources. Should you use cdk or boto-3?

Consider if your application needs AWS services and resources at build time or run time.

Build time: you need the AWS resources to be available IN ORDER TO build the application.

Run time: you need the AWS resources to be available via API call when your application is up and running.

AWS CDK setups the infrastructure your application needs in order to run.

AWS SDK compliments your application to provide business logic and to make services available through your application.

Another point to add is that AWS CDK manages the state of your deployed resources internally, thus allowing you to keep track of what has been deployed and to specify the desired state of your final deployed resources.

On the other hand, if you're using AWS SDK, you have to store and manage the state of the deployed resources (deployed using AWS SDK) yourself.

kayuapi_my
  • 498
  • 1
  • 6
  • 9
1

I am also new to AWS, here is my understanding for relevant AWS services and boto3

  • AWS Cloud Development Kit (CDK) is a software library, available in different programming languages, to define and provision cloud infrastructure*, through AWS CloudFormation.

  • Boto3 is a Python software development kit (SDK) to create, configure, and manage AWS services.

  • AWS CloudFormation is a low-level service to create a collection of relation AWS and third-party resources, and provision and manage them in an orderly and predictable fashion.

  • AWS Elastic Beanstalk is a high-level service to deploy and run applications in the cloud easily, and sits on top of AWS CloudFormation.

yoonghm
  • 4,198
  • 1
  • 32
  • 48