SecretCache - AWS Secrets Manager

SecretCache

An in-memory cache for secrets retrieved from Secrets Manager. You use get_secret_string or get_secret_binary to retrieve a secret from the cache. You can configure the cache settings by passing in a SecretCacheConfig object in the constructor.

For more information, including examples, see Get a Secrets Manager secret value using Python with client-side caching.

cache = SecretCache( config = SecretCacheConfig, client = client )
These are the available methods:

get_secret_string

Retrieves the secret string value.

Request syntax
response = cache.get_secret_string( secret_id='string', version_stage='string' )
Parameters
  • secret_id (string) -- [Required] The name or ARN of the secret.

  • version_stage (string) -- The version of secrets that you want to retrieve. For more information, see secret versions. The default is 'AWSCURRENT'.

Return type

string

get_secret_binary

Retrieves the secret binary value.

Request syntax
response = cache.get_secret_binary( secret_id='string', version_stage='string' )
Parameters
  • secret_id (string) -- [Required] The name or ARN of the secret.

  • version_stage (string) -- The version of secrets that you want to retrieve. For more information, see secret versions. The default is 'AWSCURRENT'.

Return type

base64-encoded string