Begin with AWS SDK

To perform this step, you need to generate an Access key that is used to configure the AWS CLI and install Python and Boto3.

The SDK includes two main Python packages: Botocore (a library that provides low-level functionality shared between the Python SDK and the AWS CLI) and Boto3 (the main Python SDK implementation package).

In this lab, we use Boto3

Client provides a low-level interface to the AWS service. Their definitions are generated by the JSON service description included in the botocore library. The botocore package is shared between boto3 as well as the AWS CLI.

Service definitions for AWS S3 are stored as JSON in the botocore package.

The main benefits of using the Boto3 Client application are:

  • It maps 1:1 with the actual AWS service API.
  • All AWS service operations are supported by Client

For example, if you want to list all S3 buckets in your AWS account, you can use the S3 Client as follows:

import boto3

# Retrieve the list of existing buckets
s3 = boto3.client("s3")
response = s3.list_buckets()

# Output the bucket names
print("Existing buckets:")
for bucket in response['Buckets']:
    print(f'{bucket["Name"]}')

Resource is a higher level abstraction than clients. They are generated from the JSON resource description contained in the boto library itself.

The resource provides an object-oriented interface for interacting with various AWS services. Resources can be initialized as follows:

The example below is a Resource definition for S3 .

import boto3

s3 = boto3.resource("s3")

Content