Repository navigation
feat(python): accept a credentials object for token signing - #19
Merged
Merged
Conversation
Lets a caller sign with a credentials object it already holds — the one behind an existing boto3 client, for instance — instead of a session. Credentials take precedence over the session and are still re-read per token, so rotation is preserved.
mwaisaida-13
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, this is a clean addition! A few things before merge:
-
CHANGELOG, please add the new parameter under Unreleased / Added. -
README. The Credentials section only describes the default chain. Could you add a short "bring your own credentials" paragraph with the snippet from the PR description?
mwaisaida-13
approved these changes
Oct 13, 2026
shohamazon
added a commit
to awslabs/elasticache-integration-client
that referenced
this pull request
Oct 15, 2026
Replaces the client() factory. The application builds its own client — profile, botocore Config, endpoint — and install() hooks into it, so none of that has to be mirrored here. The service name and region_name go with it: the service is in the botocore event name, the region and credentials are on the client. Bumps the IAM toolkit pin for its credentials parameter (aws/developer-toolkit-elasticache#19). A failed bring-up no longer closes the client, which is the caller's.
shohamazon
added a commit
to awslabs/elasticache-integration-client
that referenced
this pull request
Oct 18, 2026
Replaces the client() factory. The application builds its own client — profile, botocore Config, endpoint — and install() hooks into it, so none of that has to be mirrored here. The service name and region_name go with it: the service is in the botocore event name, the region and credentials are on the client. Bumps the IAM toolkit pin for its credentials parameter (aws/developer-toolkit-elasticache#19). A failed bring-up no longer closes the client, which is the caller's.
shohamazon
added a commit
to awslabs/elasticache-integration-client
that referenced
this pull request
Oct 18, 2026
* python: install into the application's own boto3 client Replaces the client() factory. The application builds its own client — profile, botocore Config, endpoint — and install() hooks into it, so none of that has to be mirrored here. The service name and region_name go with it: the service is in the botocore event name, the region and credentials are on the client. Bumps the IAM toolkit pin for its credentials parameter (aws/developer-toolkit-elasticache#19). A failed bring-up no longer closes the client, which is the caller's. * python: enforce a single install and clean up a failed one A second install() is refused: botocore silently ignores a duplicate handler, so the second session would run behind a handler that never fires. Closing restores boto3's own close(), so install/close cycles do not stack. A failed hook install now closes the session, which owns a connection and background threads. Documents install() and the cache-side arguments, verify and ca_certs included. * python: close the client even if detaching fails _close() left the client open with our close() still installed if session.close() raised. The detach steps now run in a try, and the client's own close is restored and called in a finally.
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.
What
Adds an optional
credentialsparameter togenerate_iam_auth_token,ElastiCacheIAMAuthTokenProvider, andElastiCacheIAMAuthTokenManager, so a caller can sign with a botocore credentials object it already holds instead of supplying a session.credentialstakes precedence when both are given. Existing callers are unaffected.Why
A client that integrates with an application's existing boto3 client has the credentials behind that client but not the session it was created from — a boto3 client keeps no reference back to one. Today the only way to sign a cache token with the application's own identity is to ask it for the session as well, which is an extra argument that exists purely to reach
get_credentials().The session was already used for just two things:
get_credentials()and, as a last fallback,get_config_variable("region"). A caller that passes a region explicitly only needs the first.Rotation is preserved
_resolve_credentialsstill re-reads per token request and callsget_frozen_credentials(), so a refreshable credentials object refreshes itself exactly as the session's would: the refresh callable is captured inside the object when the chain resolves it, so it needs nothing from the session afterwards. The new tests cover aRefreshableCredentialsobject vending rotated keys across twoget_token()calls.