Amazon Web Services (AWS) provides three different Python libraries interacting with their cloud services: Boto, Boto3, and Botocore. In this article, we will look at the differences between these three libraries and which one you should be using.
AWS Boto was the first AWS SDK for Python. Developers can use it to create, configure and manage AWS services like EC2 and S3. The boto package was hand-coded and thus, it was harder to maintain and add new AWS services.
The boto package has been deprecated and is no longer officially supported.
AWS Botocore provides a low-level interface to AWS services and is the foundation for the Boto3 library as well as the AWS CLI. The low level interfaces are driven from JSON service descriptions that are generated automatically from the canonical descriptions of the services. This makes it easier to add new services as well as maintaining existing services and keeping them up to date.
For example, the service definition for IAM can be found here.
It is possible to use the botocore library to interact directly with AWS services. For example, if you wanted to query EC2 to get a list of instances:
import botocore.session session = botocore.session.get_session() client = session.create_client('ec2', region_name='us-west-2') response = client.describe_instances()
Boto3 is the official Python SDK. It provides a cleaner and more Python API to interact with AWS services. It is built on top of the botocore library.
Using Boto3’s client interface will make your code a lot easier to read compared to botocore. For example, we can query EC2 to get a list of instances.
import boto3 ec2 = boto3.client('ec2') response = ec2.describe_instances()
Boto3 exposes two interfaces for interacting with AWS: Clients and Resources
Boto was the first AWS Python SDK. However, it has been deprecated and not recommended for use.
Boto3 is the official AWS Python SDK. It is built on top of the botocore library that is the foundation for both Boto3 and the AWS CLI.