Crates.io | aws_secretsmanager_caching |
lib.rs | aws_secretsmanager_caching |
version | 1.0.0 |
source | src |
created_at | 2024-07-31 23:00:52.977572 |
updated_at | 2024-07-31 23:00:52.977572 |
description | The AWS Secrets Manager Rust caching client enables in-process caching of secrets for Rust applications. |
homepage | https://github.com/aws/aws-secretsmanager-agent/aws_secretsmanager_caching |
repository | https://github.com/aws/aws-secretsmanager-agent |
max_upload_size | |
id | 1321381 |
size | 50,150 |
The AWS Secrets Manager Rust Caching Client enables in-process caching of secrets for Rust applications.
To use this client you must have:
The following code sample demonstrates how to get started:
cargo add tokio -F rt-multi-thread,net,macros
cargo add aws_secretsmanager_caching
use aws_secretsmanager_caching::SecretsManagerCachingClient;
use std::num::NonZeroUsize;
use std::time::Duration;
let client = match SecretsManagerCachingClient::default(
NonZeroUsize::new(1000).unwrap(),
Duration::from_secs(300),
)
.await
{
Ok(c) => c,
Err(_) => panic!("Handle this error"),
};
let secret_string = match client.get_secret_value("MyTest", None, None).await {
Ok(s) => s.secret_string.unwrap(),
Err(_) => panic!("Handle this error"),
};
// Your code here
max_size: NonZeroUsize
: The maximum number of cached secrets to maintain before evicting secrets that have not been accessed recently.ttl: Duration
: The duration a cached item is considered valid before requiring a refresh of the secret state.cargo add aws_sdk_secretsmanager aws_config
let config = aws_config::load_defaults(BehaviorVersion::latest())
.await
.into_builder()
.region(Region::from_static("us-west-2"))
.build();
let asm_builder = aws_sdk_secretsmanager::config::Builder::from(&config);
let client = match SecretsManagerCachingClient::from_builder(
asm_builder,
NonZeroUsize::new(1000).unwrap(),
Duration::from_secs(300),
)
.await
{
Ok(c) => c,
Err(_) => panic!("Handle this error"),
};
let secret_string = client
.get_secret_value("MyTest", None, None)
.await
{
Ok(c) => c.secret_string.unwrap(),
Err(_) => panic!("Handle this error"),
};
// Your code here
Please use these community resources for getting help: