aws-secrets

Crates.ioaws-secrets
lib.rsaws-secrets
version0.1.1
sourcesrc
created_at2022-08-26 22:17:48.081375
updated_at2022-08-27 02:16:01.330098
descriptionRetrieve AWS secrets and interact with Secrets Manager and SSM Parameter Store
homepage
repositoryhttps://github.com/rnag/aws-secrets
max_upload_size
id653081
size91,698
Ritvik Nag (rnag)

documentation

https://docs.rs/aws-secrets

README

aws-secrets

github crates.io docs.rs build status

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"] }

Getting started

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(())
}

Examples

You can check out sample usage of this crate in the examples/ folder in the project repo on GitHub.

Dependencies and Features

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.

Available features

  • 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.

Enabling Features

Update the project's Cargo.toml to include any optional features to enable:

[dependencies]
aws-secrets = { version = "*", features = ["all"] }

Contributing

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.

License

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.

Authors

Commit count: 10

cargo fmt