Skip to content

Configuration

Configuration

Everything is a client argument:

from capo_s3 import AsyncS3Client

AsyncS3Client(region="eu-central-1")

# S3-compatible server (RustFS, MinIO, LocalStack, ...)
AsyncS3Client(
    endpoint="http://localhost:9000",
    force_path_style=True,
    region="us-east-1",
    credentials={"access_key": "rustfsadmin", "secret_key": "rustfsadmin"},
)

AsyncS3Client(use_fips=True)
AsyncS3Client(use_dual_stack=True)
AsyncS3Client(accelerate=True)  # S3 Transfer Acceleration
AsyncS3Client(retry_max_attempts=5)

Or a per-call override:

async with AsyncS3Client(region="eu-central-1") as s3:
    await s3.head_bucket("us-bucket", config_overrides={"region": "us-west-2"})
    await s3.head_bucket(
        "local",
        config_overrides={"endpoint": "http://localhost:9000", "force_path_style": True},
    )

Or environment variables:

export AWS_REGION=eu-central-1
export AWS_ENDPOINT_URL_S3=http://localhost:9000   # this service only
export AWS_ENDPOINT_URL=http://localhost:4566      # every service
export AWS_USE_FIPS_ENDPOINT=true
export AWS_USE_DUALSTACK_ENDPOINT=true
export AWS_MAX_ATTEMPTS=5
export AWS_PROFILE=dev                             # or AWS_DEFAULT_PROFILE
export AWS_CONFIG_FILE=~/.aws/config

Or the active profile in ~/.aws/config:

[profile dev]
region = eu-central-1
endpoint_url = http://localhost:4566
use_fips_endpoint = false
use_dualstack_endpoint = false
max_attempts = 5
services = local

[services local]
s3 =
  endpoint_url = http://localhost:9000

First match wins: config_overrides, then the client argument, then the environment variable, then the profile. For the endpoint the order within the environment and the profile is AWS_ENDPOINT_URL_S3, AWS_ENDPOINT_URL, the [services] entry, then the profile's endpoint_url.