AWS SDK for Python (boto3)

1.42.59 · active · verified Sun Mar 01

Official AWS SDK for Python. Extremely stable API — no breaking changes since v1.0. Two client styles: low-level client (boto3.client()) and high-level resource (boto3.resource()). Credential resolution follows a fixed chain. Region must be specified or set in environment — no global default. Released daily with new AWS service additions.

Warnings

Install

Imports

Quickstart

Credential chain order: (1) explicit in code, (2) env vars AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, (3) ~/.aws/credentials, (4) ~/.aws/config, (5) EC2/ECS instance metadata.

import boto3
from botocore.exceptions import ClientError, NoCredentialsError

# Credential chain: env vars → ~/.aws/credentials → IAM role → ...
# Set AWS_DEFAULT_REGION or pass region_name explicitly
client = boto3.client('s3', region_name='us-east-1')

try:
    # List buckets
    response = client.list_buckets()
    for bucket in response['Buckets']:
        print(bucket['Name'])
except NoCredentialsError:
    print('No AWS credentials found')
except ClientError as e:
    print(f"Error: {e.response['Error']['Code']}: {e.response['Error']['Message']}")

view raw JSON →