Including secrets in your deployment
Secrets.toml
to the crate root or workspace root of your Shuttle service with the secrets you’d like to store.
Make sure to add Secrets*.toml
to a .gitignore
to omit your secrets from version control.
The format of the Secrets.toml file is a key-value mapping with string values.
#[shuttle_runtime::Secrets] secrets: shuttle_runtime::SecretStore
as an argument to your shuttle_runtime::main
function.
SecretStore::get
can now be called to retrieve your API keys and other secrets at runtime.
shuttle run
, you can use a different set of secrets by adding a Secrets.dev.toml
file.
If you don’t have a Secrets.dev.toml
file, Secrets.toml
will be used locally as well as for deployments.
If you want to have both secret files with some of the same secrets for both local runs and deployments, you have to duplicate the secret across both files.
--secrets [file]
argument on the run
and deploy
commands.
shuttle_runtime::Secrets
attribute to gain access to a SecretStore
.
Secrets.toml
to add them back.
std::env::set_var("SOME_ENV_VAR", my_secret);