Repository navigation
Conversation
…vider Add KmsTransport and TenantKmsClient so the ESDK-Python can call AWS KMS with per-tenant credentials over one shared connection pool, without a boto3 Session or client per tenant. Add a StrictAwsKmsMasterKeyProvider subclass that uses them, a design document, and offline and integration tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
boto3 binds AWS credentials to a client at construction, and every boto3 client (and Session) owns its own connection pool. An application that must call KMS with per-tenant credentials therefore needs a Session and KMS client per tenant; measured at ~239 ms and ~8.4 MiB each, that does not scale to hundreds or thousands of tenants.
This adds an example that shares one connection pool across every tenant:
examples/src/multi_tenant/kms_transport.py:KmsTransport, one per process. Oneurllib3pool, SigV4 signing viabotocore.auth.SigV4Auth, basic retries modeled on botocore's standard mode, and the same exception types boto3 raises (mapping mirrorsbotocore/httpsession.py).examples/src/multi_tenant/tenant_kms_client.py:TenantKmsClient, one per tenant per region. A boto3-shaped client forGenerateDataKey,GenerateDataKeyWithoutPlaintext,Encrypt,Decrypt, andReEncrypt; it holds only a transport reference, a region, and the tenant's credentials.examples/src/legacy/multi_tenant_kms_master_key_provider.py:TenantStrictAwsKmsMasterKeyProvider, aStrictAwsKmsMasterKeyProviderwhose regional clients areTenantKmsClients.examples/src/multi_tenant/design.md: the options considered and the decisions made.This PR is the first chunk. Keyring (AWS KMS, MRK discovery multi-keyring, Hierarchical) examples and the MRK-aware/Discovery MKPs will follow separately;
design.mdalready describes them.Testing
test_i_multi_tenant_kms_master_key_providerpasses. Separately confirmed that requests signed with two different credential sets share one TLS connection.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Check any applicable:
🤖 Generated with Claude Code