Variables and secrets

What an app runs with, and what is sealed.

On this page

Variables configure an app without changing its code. They are set on the server and override the [env] of moorage.toml.

The Variables tab: each variable with its value or dots for a secret, where it comes from, and buttons to reveal, change or remove itThe Variables tab: each variable with its value or dots for a secret, where it comes from, and buttons to reveal, change or remove it
An app's Variables tab says where each one comes from.
moor env set LOG_LEVEL=debug FEATURE_X=on

Every change is a new release of the app's current build, rolled out like a deploy: new instances start with the new variables, take the traffic once healthy, and the old ones stop. Nothing is dropped. --no-restart keeps the change for the next deploy instead. Variables can be set before the first deploy.

moor env

lists them with where each comes from (this environment, every environment, or moorage.toml) and which ones another source overrides.

Secrets#

moor env set --secret DATABASE_URL

asks for the value without showing it (or reads it from standard input: moor env set --secret DATABASE_URL < url.txt), so it stays out of your shell's history. A secret is stored encrypted, listed without its value, handed to the app without being written to disk, and replaced by [secret] where the app, its build or its release command prints it (for values of six characters or more). A maintainer can read one back with moor env reveal NAME, which is recorded in the audit log.

The key that encrypts secrets, keys/master.key in the data directory, must be backed up apart from the database. A server whose secrets were encrypted with another key, or without its key, refuses to start.

What an app expects#

An app can say what it needs, with no values in the repository:

[vars.PAYMENTS_KEY]
required = true
secret = true
description = "Sandbox key for the payments provider"

[vars.SESSION_KEY]
generate = "secret"

A deployment that lacks one that is required fails early, saying which, before the app gets as far as falling over, and one that is secret must have been set as one. One to generate is made the first time it is needed, once for each environment, so that every preview gets its own. Rollbacks do not stop to check. moor env and the app's Variables page list them all, with their descriptions, and say what is missing.

In other environments#

A variable belongs to one environment, or with --all-envs to all of them. A preview also inherits production's, and shows them as inherited; setting one of the same name on the preview overrides it. Keep one from previews with --production-only:

moor env set --secret --production-only STRIPE_KEY

More#

Suggest a change to this page