Boto (AWS SDK v2)

2.49.0 · abandoned · verified Thu Apr 09

Boto is the legacy Python SDK for Amazon Web Services (AWS), providing an object-oriented interface to AWS services. Its last release was 2.49.0 in 2017. The project is no longer actively maintained and has been superseded by `boto3`, which is the current official AWS SDK for Python.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to connect to Amazon S3 using `boto` and list all available buckets. It highlights the use of environment variables for credentials, a common practice in `boto` and `boto3`.

import boto
import os

# Ensure AWS credentials are set as environment variables (recommended)
# For example: export AWS_ACCESS_KEY_ID='AKIA...'
#             export AWS_SECRET_ACCESS_KEY='your_secret_key...'

# Boto 2 primarily supports Python 2, and while it might run on Python 3,
# boto3 is the recommended and actively maintained SDK for Python 3.

try:
    # Connect to S3 using credentials from environment variables
    # or explicitly provided arguments
    conn = boto.connect_s3(
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_AWS_ACCESS_KEY_ID'),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_AWS_SECRET_ACCESS_KEY')
    )

    # List all buckets
    print("Listing S3 buckets:")
    buckets = conn.get_all_buckets()
    if buckets:
        for bucket in buckets:
            print(f"- {bucket.name}")
    else:
        print("No S3 buckets found.")

except boto.exception.S3ResponseError as e:
    print(f"S3 Error: {e.reason} - {e.error_code} - {e.message}")
    print("Please check your AWS credentials and region settings.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →