Boto3 is the Amazon Web Services (AWS) SDK for Python. It enables Python developers to create, configure, and manage AWS services, such as EC2 and S3. Boto3 provides an easy to use, object-oriented API, as well as low-level access to AWS services.

Boto3 is written on top of botocore which is a low-level interface to the AWS API. Botocore is the basis for the AWS-CLI.

Prerequisites:

activate virtual environment by entering below command in Anaconda Prompt

activate forcloud

Here “forcloud” is name of the virtual environment

Activate Python Virtual Environment

Install boto3 and awscli in this environment

pip install awscli boto3

Install boto3 awscli

Configure IAM Access Key in the AWS CLI

Using Boto 3

To use Boto 3, you must first import it and tell it what service you are going to use:

import boto3

# Let's use Amazon S3
s3 = boto3.resource('s3')

Now that you have an s3 resource, you can make requests and process responses from the service. The following uses the buckets collection to print out all bucket names:

# Print out bucket names
for bucket in s3.buckets.all():
    print(bucket.name)


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *