aws_secrets/lib.rs
1#![doc(html_root_url = "https://docs.rs/aws-secrets/0.1.1")]
2#![warn(rust_2018_idioms, missing_docs)]
3#![deny(warnings, dead_code, unused_imports, unused_mut)]
4
5//! [![github]](https://github.com/rnag/aws-secrets) [![crates-io]](https://crates.io/crates/aws-secrets) [![docs-rs]](https://docs.rs/aws-secrets)
6//!
7//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
8//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
9//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
10//!
11//! <br>
12//!
13//! Retrieve AWS secrets and interact with [Secrets Manager] and [SSM Parameter Store].
14//!
15//! [Secrets Manager]: https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html
16//! [SSM Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html
17//!
18//! <br>
19//!
20//! ## Usage
21//!
22//! > Note: this example requires the `all` feature to be enabled.
23//!
24//! ```no_run
25//! use aws_secrets::{config_from_env, SSMParamExt, SecretsExt};
26//! use serde_json::{to_string, Value};
27//!
28//! #[tokio::main]
29//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
30//! let shared_config = config_from_env().await;
31//!
32//! // Retrieve a secret from AWS Secrets Manager
33//! let secret_name = "my-secret";
34//! let value: Value = secret_name.get_secret(&shared_config).await?;
35//! let secret_string = to_string(&value)?;
36//! println!("[{secret_name}] Retrieved secret. value={secret_string}");
37//!
38//! // Retrieve a parameter from AWS SSM Parameter Store
39//! let param_name = "/my/secure/param";
40//! let value = param_name.get_secure_string(&shared_config).await?;
41//! println!("[{param_name}] Retrieved parameter. value={value:?}");
42//!
43//! Ok(())
44//! }
45//! ```
46//!
47//! ## Examples
48//!
49//! You can check out sample usage of this crate in the [examples/](https://github.com/rnag/aws-secrets/tree/main/examples)
50//! folder in the project repo on GitHub.
51//!
52//! ## Readme Docs
53//!
54//! You can find the crate's readme documentation on the
55//! [crates.io] page, or alternatively in the [`README.md`] file on the GitHub project repo.
56//!
57//! ## Dependencies and Features
58//!
59//! This library uses only the minimum required dependencies, in order
60//! to keep the overall size small. It leverages the [AWS SDK for Rust]
61//! for making calls to AWS APIs.
62//!
63//! > **Note:** Any desired features must be enabled individually, as no features are enabled by default.
64//!
65//! #### Available features
66//!
67//! * `all` - Enables support for AWS Secrets Manager and SSM Parameter Store.
68//! * `params` - Enables support for AWS SSM Parameter Store.
69//! * `sm` - Enables support for AWS Secrets Manager.
70//!
71//! #### Enabling Features
72//!
73//! Update the project's `Cargo.toml` to include any optional features to enable:
74//! ```toml
75//! [dependencies]
76//! aws-secrets = { version = "*", features = ["all"] }
77//! ```
78//!
79//! [AWS SDK for Rust]: https://docs.aws.amazon.com/sdk-for-rust/latest/dg/using.html
80//!
81//! [crates.io]: https://crates.io/crates/aws-secrets
82//! [`README.md`]: https://github.com/rnag/aws-secrets
83//!
84
85mod errors;
86#[cfg(feature = "params")]
87mod params;
88#[cfg(feature = "sm")]
89mod secretsmanager;
90mod types;
91
92pub use aws_config as config;
93pub use aws_config::load_from_env as config_from_env;
94pub use errors::Error;
95#[cfg(feature = "params")]
96pub use params::SSMParamExt;
97#[cfg(feature = "sm")]
98pub use secretsmanager::SecretsExt;
99pub use types::Result;
100
101#[cfg(test)]
102mod tests {
103 #[test]
104 fn it_works() {
105 let result = 2 + 2;
106 assert_eq!(result, 4);
107 }
108}