Currently, get_session caches sessions in a single variable, and the cached session takes priority over explicitly-passed-in parameters. This means that there can only be a single Session each time credstash is imported, which is set the first time get_session is called. All subsequent calls to get_session return that session, regardless of input.
This PR adds aliased caching by aws_access_key_id to get_session. On the first call with any aws_access_key_id, a Session is created and stored in a dictionary. All subsequent calls with that AKID will re-use the cached Session. The existing caching behavior, where a call to get_session returns the last-used Session is maintained using a last_session variable.
Both the cache and last_session can be reset by calling reset_sessions.
Resolves #255
Currently,
get_session
caches sessions in a single variable, and the cached session takes priority over explicitly-passed-in parameters. This means that there can only be a singleSession
each timecredstash
is imported, which is set the first timeget_session
is called. All subsequent calls toget_session
return that session, regardless of input.This PR adds aliased caching by
aws_access_key_id
toget_session
. On the first call with anyaws_access_key_id
, aSession
is created and stored in a dictionary. All subsequent calls with that AKID will re-use the cachedSession
. The existing caching behavior, where a call toget_session
returns the last-usedSession
is maintained using alast_session
variable.Both the cache and
last_session
can be reset by callingreset_sessions
.