@InjectKeywordedSecretString - Amazon Secrets Manager
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


This decorator expects a secret ID string and SecretCache as the first and second arguments. The remaining arguments map parameters from the wrapped function to JSON keys in the secret. The secret must contain a string in JSON structure.

For a secret that contains this JSON:

{ "username": "saanvi", "password": "EXAMPLE-PASSWORD" }

The following example shows how to extract the JSON values for username and password from the secret.

from aws_secretsmanager_caching import SecretCache from aws_secretsmanager_caching import InjectKeywordedSecretString, InjectSecretString cache = SecretCache() @InjectKeywordedSecretString ( secret_id = 'mysecret' , cache = cache , func_username = 'username' , func_password = 'password' ) def function_to_be_decorated( func_username, func_password): print( 'Do something with the func_username and func_password parameters')