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

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

使用 Rust Amazon SDK 获取 Secrets Manager 的密钥值

在应用程序中,您可以通过调用GetSecretValueBatchGetSecretValue在任一应用程序中检索您的秘密 Amazon SDKs。不过,我们建议您通过使用客户端缓存来缓存您的密钥值。缓存密钥可以提高速度并降低成本。

对于 Rust 应用程序,请使用基于 Secrets Manager 的 Rust 缓存组件,或者使用或直接调用 SDK。 GetSecretValue BatchGetSecretValue

以下代码示例展示了如何获取 Secrets Manager 密钥值。

所需权限:secretsmanager:GetSecretValue

async fn show_secret(client: &Client, name: &str) -> Result<(), Error> { let resp = client.get_secret_value().secret_id(name).send().await?; println!("Value: {}", resp.secret_string().unwrap_or("No value!")); Ok(()) }