boto3
# 1. Point at your gateway, not AWS
import boto3
s3 = boto3.client(
"s3",
endpoint_url="https://your-gateway:9000",
aws_access_key_id="AKIA...",
aws_secret_access_key="...",
)
# 2. Set bucket default encryption (SSE-S3, AES256) — persists, real config
s3.put_bucket_encryption(
Bucket="my-bucket",
ServerSideEncryptionConfiguration={
"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}]
},
)
# 3. Confirm it round-trips
cfg = s3.get_bucket_encryption(Bucket="my-bucket")
print(cfg["ServerSideEncryptionConfiguration"])
# 4. Upload with the SSE-S3 header — accepted; the shard layer is
# already always-on XChaCha20-encrypted independent of this header
s3.put_object(
Bucket="my-bucket",
Key="report.pdf",
Body=open("report.pdf", "rb"),
ServerSideEncryption="AES256",
)
# 5. SSE-C is out of model — we never take your key. This raises NotImplemented.
# Want to hold the key yourself? Encrypt the bytes before you upload.
# s3.put_object(Bucket="my-bucket", Key="x", Body=b"...",
# SSECustomerAlgorithm="AES256", SSECustomerKey=key)
# botocore.exceptions.ClientError: NotImplemented —
# "SSE-C (customer-provided keys) is not supported by this gateway."