Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
@InjectKeywordedSecretString
Ce décorateur attend une chaîne d'identité secrète et SecretCache comme premier et deuxième arguments. Les arguments restants mappent les paramètres de la fonction encapsulée aux clés JSON du secret. Le secret doit contenir une chaîne dans la structure JSON.
Pour un secret contenant ce JSON :
{ "username": "
saanvi
", "password": "EXAMPLE-PASSWORD
" }
L'exemple suivant montre comment extraire du secret les valeurs JSON pour username
et password
.
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' ) deffunction_to_be_decorated
( func_username, func_password): print( 'Do something with the func_username and func_password parameters')