Loading...
 
AWS SDK for Python Boto3 makes it easy to integrate your Python application, library, or script with AWS services

AWS SDK for Python (Boto3)

AWS SDK for Python Boto3 makes it easy to integrate your Python application, library, or script with AWS services including Amazon S3, Amazon EC2, Amazon DynamoDB, and more.1

The AWS SDK for Python Boto3 uses the Amazon Web Services Botocore

Video

AWS re:Invent 2014 | (DEV307) Introduction to Version 3 of the AWS SDK for Python (Boto)

References

  • boto3 GitHub
  • AWS SDK For Python (Boto3)
  • Quickstart - Getting started with Boto 3 is easy, but requires a few steps.
  • Boto 3 Documentation - Boto is the Amazon Web Services (AWS) SDK for Python, which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.

New Project

Linux

Where is Python 3 installed...

which python3

Use the results of the which command to create the virtualenv, for example /usr/bin/python3

virtualenv myawsproject -p /usr/bin/python3

Activate the virtualenv

cd myawsproject
source bin/activate

Install boto3

(myawsproject)pip install boto3

Python

import boto3

Credentials

Boto can be configured in multiple ways. Regardless of the source or sources that you choose, you must have AWS credentials and a region set in order to make requests.2

The mechanism in which boto3 looks for credentials is to search through a list of possible locations and stop as soon as it finds credentials. The order in which Boto3 searches for credentials is:3

  1. Passing credentials as parameters in the boto.client() method
  2. Passing credentials as parameters when creating a Session object
  3. Environment variables
  4. Shared credential file (~/.aws/credentials) (see AWS Command Line Interface)
  5. AWS config file (~/.aws/config)
  6. Assume Role provider
  7. Boto2 config file (/etc/boto.cfg and ~/.boto)
  8. Instance metadata service on an Amazon EC2 instance that has an IAM role configured.
session = boto3.Session(profile_name='dev')
# Any clients created from this session will use credentials
# from the [dev] section of ~/.aws/credentials.
dev_s3_client = session.client('s3')

Last edited by MichaelAlber .
Page last modified on Sunday May 19, 2019 18:42:30 UTC.