SecretCache - Amazon Secrets Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

SecretCache

适用于从 Secrets Manager 检索的密钥的内存中缓存。您使用 get_secret_stringget_secret_binary 从缓存中检索密钥。您可以通过传入构造函数中的 SecretCacheConfig 对象来配置缓存设置。

有关包括示例在内的更多信息,请参阅 检索 Python 应用程序中的 Amazon Secrets Manager 密钥

cache = SecretCache( config = SecretCacheConfig, client = client )
以下是可用方法:

get_secret_string

检索密钥字符串值。

请求语法
response = cache.get_secret_string( secret_id='string', version_stage='string' )
参数
  • secret_id (字符串) -- [必需] 密钥的名称或 ARN。

  • version_stage (字符串) -- 您要检索的密钥的版本。有关更多信息,请参阅密钥版本。默认值为“AWSCURRENT”。

返回类型

字符串

get_secret_binary

检索密钥二进制值。

请求语法
response = cache.get_secret_binary( secret_id='string', version_stage='string' )
参数
  • secret_id (字符串) -- [必需] 密钥的名称或 ARN。

  • version_stage (字符串) -- 您要检索的密钥的版本。有关更多信息,请参阅密钥版本。默认值为“AWSCURRENT”。

返回类型

base64 编码的字符串