Expand description
§grow-aws-secrets-manager
Rust SDK for AWS Secrets Manager
by Grow Codes, built on the official AWS SDK for Rust (aws-sdk-secretsmanager).
use grow_aws_secrets_manager::secrets::SecretsProvider;
use grow_aws_secrets_manager::{AwsSecretsManagerClient, AwsSecretsManagerConfig};
use grow_aws_secrets_manager::models::GetSecretValueOptions;
let client = AwsSecretsManagerClient::new(AwsSecretsManagerConfig::from_env()?)?;
let secret = client.get_secret_value("prod/db", GetSecretValueOptions::default()).await?;
println!("version {:?}", secret.version_id); // the value itself prints as [REDACTED]
let password = client.get_json_field("prod/db", "password", Default::default()).await?;
let provider = client.secrets();
let api_key = provider.get_string("prod/api-key", None).await?;
client.close().await;Features: blocking (a blocking client), testing (in-memory fakes and the conformance
runner).
Not affiliated with or endorsed by Amazon Web Services. AWS and AWS Secrets Manager are trademarks of Amazon.com, Inc. or its affiliates.
Re-exports§
pub use crate::core::Error;pub use crate::core::ErrorCode;pub use crate::core::HealthStatus;pub use crate::core::Result;pub use crate::core::RetryPolicy;pub use crate::core::Secret;pub use crate::models::API_VERSION;pub use crate::models::AWSCURRENT;pub use crate::models::AWSPENDING;pub use crate::models::AWSPREVIOUS;pub use crate::models::BATCH_GET_MAX_IDS;pub use aws_sdk_secretsmanager;
Modules§
- blocking
blocking - Blocking wrapper (feature
blocking). Each client owns a tokio runtime with one worker thread, so background work (watchers, retries’ timers) keeps running between blocking calls. - core
- Shared core: errors, configuration, secrets in config, redaction, retries and transport.
- models
- Models of the AWS Secrets Manager API, request options and converters from the AWS SDK
shapes. Secret values are always wrapped in the redacting
SecretValue. - secrets
- Secrets category: values, provider traits, cache, watch and
load_env(SPEC §3). - testing
testing - Test support (feature
testing): in-memory fakes and the conformance runner (SPEC §6).
Structs§
- AwsError
Detail - Redacted details of an AWS error, kept as the
Errorsource. It never holds the raw response (which could echo request data). - AwsSecret
Cache - Version-stage aware cache in front of an
AwsSecretsManagerClient(client.secret_cache(opts)). Reads are coalesced per(secret_id, stage). A refresh that fails keeps serving the cached value and retries with exponential backoff (AWS caching-client behaviour); a first read that fails returns the error. - AwsSecret
Cache Options - Options of
AwsSecretCache. - AwsSecret
Cache Stats - Counters reported by
AwsSecretCache::stats. - AwsSecrets
Manager Client - Async client for AWS Secrets Manager. Cheap to clone (clones share one SDK client).
- AwsSecrets
Manager Config - Immutable client configuration; build it with
AwsSecretsManagerConfig::builderorAwsSecretsManagerConfig::from_env.Debugoutput redacts every credential. - AwsSecrets
Manager Config Builder - Builder for
AwsSecretsManagerConfig. Values set here win over the environment. - AwsSecrets
Manager Secrets Options - Options of
AwsSecretsManagerClient::secrets_with_options. - AwsSecrets
Manager Secrets Provider SecretsProviderover AWS Secrets Manager (client.secrets()). Capabilities:write,versions,delete.- Paginator
- Lazy iterator over every page of a list call. Nothing is sent until the first
next,next_pageortry_collect.
Constants§
- AWS_
ERROR_ CODES - AWS error code → Grow
ErrorCode(API.md §1.1). - AWS_
SECRET_ CACHE_ MAX_ ENTRIES - Capacity of the AWS caching clients (1 024 entries).
- AWS_
SECRET_ CACHE_ TTL - TTL of the AWS caching clients (1 h).
- DEFAULT_
RECOVERY_ WINDOW_ DAYS - Default recovery window of
delete_secret/SecretsProvider::deletein days (AWS default). - DEFAULT_
ROLE_ SESSION_ NAME - Default STS role session name of the assume-role helper.
- DEFAULT_
URL - Informational endpoint used when no endpoint override is set and no region is known. The AWS
SDK resolves the real endpoint (
https://secretsmanager.<region>.amazonaws.com) itself. - VENDOR_
PROFILE_ VARS - Vendor variables checked after
GROW_AWS_SECRETS_MANAGER_PROFILE. - VENDOR_
REGION_ VARS - Vendor variables checked (in order) after
GROW_AWS_SECRETS_MANAGER_REGION. - VENDOR_
URL_ VARS - Vendor variables checked (in order) after
GROW_AWS_SECRETS_MANAGER_URL.
Traits§
- Secret
Cache Source - The client operations the cache needs (
AwsSecretsManagerClientimplements it; tests can pass a fake).
Functions§
- aws_
error_ code - The AWS error code behind an SDK error (e.g.
ResourceNotFoundException), when the error came from an AWS response with a recognisable code. - error_
code_ for_ aws - The Grow code for an AWS error code (
Nonewhen unknown). - error_
code_ from_ body - Extracts an AWS error code from an XML (
<Code>) or JSON (__type,code) error body. - full_
name path/namewhen a path is given, otherwisename.- is_
missing - Whether
errmeans “missing”:NOT_FOUND, orInvalidRequestException(the secret is scheduled for deletion). - to_
metadata - Converts a description into SPEC metadata.
Type Aliases§
- AwsSecrets
Manager Error - Service-prefixed alias of
Error. - OnRefresh
Error - Callback for refresh failures.