Coder Social home page Coder Social logo

aws-secrets's Introduction

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

aws-secrets's People

Contributors

cb-rnag avatar rnag avatar

Watchers

 avatar  avatar

Forkers

frisoft razein97

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.