Crates.io | aws-secrets |
lib.rs | aws-secrets |
version | 0.1.1 |
source | src |
created_at | 2022-08-26 22:17:48.081375 |
updated_at | 2022-08-27 02:16:01.330098 |
description | Retrieve AWS secrets and interact with Secrets Manager and SSM Parameter Store |
homepage | |
repository | https://github.com/rnag/aws-secrets |
max_upload_size | |
id | 653081 |
size | 91,698 |
Retrieve AWS secrets and interact with Secrets Manager and SSM Parameter Store.
This crate works with Cargo with a Cargo.toml
like:
[dependencies]
aws-secrets = { version = "0.1.1", features = ["all"] }
serde_json = "1" # optional
tokio = { version = "1", features = ["full"] }
Add some usage to your application. Here's an example of using aws-secrets
in code.
Note: this sample requires the
all
feature to be enabled.
use aws_secrets::{config_from_env, SSMParamExt, SecretsExt};
use serde_json::{to_string, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let shared_config = config_from_env().await;
// Retrieve a secret from AWS Secrets Manager
let secret_name = "my-secret";
let value: Value = secret_name.get_secret(&shared_config).await?;
let secret_string = to_string(&value)?;
println!("[{secret_name}] Retrieved secret. value={secret_string}");
// Retrieve a parameter from AWS SSM Parameter Store
let param_name = "/my/secure/param";
let value = param_name.get_secure_string(&shared_config).await?;
println!("[{param_name}] Retrieved parameter. value={value:?}");
Ok(())
}
You can check out sample usage of this crate in the examples/ folder in the project repo on GitHub.
This library uses only the minimum required dependencies, in order to keep the overall size small. It leverages the AWS SDK for Rust for making calls to AWS APIs.
Note: Any desired features must be enabled individually, as no features are enabled by default.
all
- Enables support for AWS Secrets Manager and SSM Parameter Store.params
- Enables support for AWS SSM Parameter Store.sm
- Enables support for AWS Secrets Manager.Update the project's Cargo.toml
to include any optional features to enable:
[dependencies]
aws-secrets = { version = "*", features = ["all"] }
Contributions are welcome! Open a pull request to fix a bug, or open an issue to discuss a new feature or change.
Check out the Contributing section in the docs for more info.
This project is proudly licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).
aws-secrets
can be distributed according to the MIT license. Contributions
will be accepted under the same license.