#shuttle-service #secrets

shuttle-secrets

Plugin to for managing secrets on shuttle

33 breaking releases

0.39.0 Feb 14, 2024
0.37.0 Jan 24, 2024
0.35.2 Dec 21, 2023
0.34.1 Nov 29, 2023
0.7.2 Oct 28, 2022

#192 in Development tools

Download history 689/week @ 2023-11-03 748/week @ 2023-11-10 1021/week @ 2023-11-17 1132/week @ 2023-11-24 883/week @ 2023-12-01 945/week @ 2023-12-08 985/week @ 2023-12-15 1255/week @ 2023-12-22 753/week @ 2023-12-29 964/week @ 2024-01-05 991/week @ 2024-01-12 981/week @ 2024-01-19 1016/week @ 2024-01-26 719/week @ 2024-02-02 1131/week @ 2024-02-09 1346/week @ 2024-02-16

4,314 downloads per month
Used in 5 crates

Apache-2.0

3KB

Shuttle Secrets

This plugin manages secrets on Shuttle.

Usage

Add shuttle-secrets to the dependencies for your service, and add a Secrets.toml to the root of your project with the secrets you'd like to store. Make sure to add Secrets*.toml to a .gitignore to omit your secrets from version control.

Next, pass #[shuttle_secrets::Secrets] secret_store: SecretStore as an argument to your shuttle_service::main function. SecretStore::get can now be called to retrieve your API keys and other secrets at runtime.

Example

#[shuttle_runtime::main]
async fn rocket(
    #[shuttle_secrets::Secrets] secret_store: SecretStore,
) -> ShuttleRocket {
    // get secret defined in `Secrets.toml` file.
    let secret = if let Some(secret) = secret_store.get("MY_API_KEY") {
        secret
    } else {
        return Err(anyhow!("secret was not found").into());
    };

    let state = MyState { secret };
    let rocket = rocket::build().mount("/", routes![secret]).manage(state);

    Ok(rocket.into())
}

Dependencies

~15–28MB
~433K SLoC