Amazon S3 Encryption Client for Python
This library provides an S3 client that supports client-side encryption. For more information and detailed instructions for how to use this library, refer to the Amazon S3 Encryption Client Developer Guide.
Getting Started
Requires Python 3.10 or greater. An AWS account is required; standard S3 and KMS charges apply.
The S3 Encryption Client wraps a standard boto3 S3 client and uses a KMS keyring to manage data key encryption. Objects are encrypted before upload and decrypted after download transparently. By default, the client uses AES-GCM with key commitment for content encryption.
import boto3
from s3_encryption import S3EncryptionClient, S3EncryptionClientConfig
from s3_encryption.materials.kms_keyring import KmsKeyring
kms_client = boto3.client("kms", region_name="us-west-2")
keyring = KmsKeyring(kms_client, "arn:aws:kms:us-west-2:123456789012:alias/my-key")
s3_client = boto3.client("s3")
config = S3EncryptionClientConfig(keyring=keyring)
s3ec = S3EncryptionClient(s3_client, config)
# Encrypt and upload
s3ec.put_object(Bucket="my-bucket", Key="my-object", Body=b"secret data")
# Download and decrypt
response = s3ec.get_object(Bucket="my-bucket", Key="my-object")
plaintext = response["Body"].read()
Development
Prerequisites
- Python 3.10 or higher
- uv for package and project management
Setup
Install dependencies:
make install
Testing
Run all tests (unit + integration + examples):
make test
Run unit tests only:
make test-unit
Run integration tests only:
make test-integration
Code Quality
This project uses Ruff for linting and formatting.
Check formatting:
make format-check
Run linter:
make lint
Format code and auto-fix lint issues:
make format
Integration Test Resources
Integration tests require AWS credentials and the following resources. The tests use environment variables to override CI defaults:
| Variable | Description | Default |
|---|---|---|
CI_S3_BUCKET |
S3 bucket for read/write tests | s3ec-python-github-test-bucket |
CI_AWS_REGION |
Primary AWS region | us-west-2 |
CI_KMS_KEY_ALIAS |
KMS key ARN or alias for encryption | arn:aws:kms:us-west-2:370957321024:alias/S3EC-Python-Github-KMS-Key |
CI_MRK_KEY_ID_PRIMARY |
Multi-region key ARN (primary region) | arn:aws:kms:us-west-2:370957321024:key/mrk-cea4cf67c6a046ba829f61f69db5c191 |
CI_MRK_KEY_ID_REPLICA |
Multi-region key ARN (replica region) | arn:aws:kms:us-east-1:370957321024:key/mrk-cea4cf67c6a046ba829f61f69db5c191 |
CI_S3_STATIC_TEST_BUCKET |
Bucket with pre-existing test objects for instruction file tests | s3ec-static-test-objects |
CI_KMS_KEY_STATIC_TESTS |
KMS key used for static test objects | arn:aws:kms:us-west-2:370957321024:key/a3889cd9-99eb-4138-a93a-aea9d52ec2ef |
To run integration tests locally, configure AWS credentials with access to these resources (or your own equivalents) and set the environment variables accordingly.
Metadata
Release files for amazon-s3-encryption-client-python 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| amazon_s3_encryption_client_python-4.0.0.tar.gz | 448.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| amazon_s3_encryption_client_python-4.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 494.8 kB
Release files / amazon_s3_encryption_client_python-4.0.0.tar.gz
| Download URL | amazon_s3_encryption_client_python-4.0.0.tar.gz |
|---|---|
| Size | 448.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ef6b28a267d8de89fc09798a65433144fa67e33e26ce4fb50199b580eeb4c4d
|
|
BLAKE2b-256 checksum How to use checksums |
640302be44a3ef25363bafa20ad18c5dfb323fdf050bb6663b15305ad46ebb63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency logRelease files / amazon_s3_encryption_client_python-4.0.0-py3-none-any.whl
| Download URL | amazon_s3_encryption_client_python-4.0.0-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5559b049a055d27d20c57bbac2c2fa306deb3b218cb7d3caaa93eac11bfb4810
|
|
BLAKE2b-256 checksum How to use checksums |
61ace8e5371bd7258d2c8092a515a33417ad0a22282459a15c0c715777e5ae39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 26, 2026.
Transparency log