

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# @InjectKeywordedSecretString
<a name="retrieving-secrets_cache-decor-keyword"></a>

このデコレータは、1 番目と 2 番目の引数として、シークレット ID 文字列と [SecretCache](retrieving-secrets_cache-ref-secretcache.md) を必要とします。残りの引数は、ラップされた関数のパラメータをシークレット内の JSON キーにマッピングします。シークレットに JSON 構造の文字列が含まれている必要があります。

この JSON を含むシークレットの場合は、次のようになります。

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

次の例では、シークレットから `username` および `password` の JSON 値を抽出する方法を示しています。

```
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')
```