Variables reach your app as environment variables: every process, the release command and the console get them. A secret is a variable whose value can’t be read back once it’s saved.
Adding a variable
- Open your app’s Variables page.
- Under Add or replace a variable, enter the Key and the Value.
- Tick Secret for passwords, tokens and keys.
- Choose Save variable.
Saving a key that already exists replaces its value. Remove takes a variable away.
You can also add variables while you create an app, under Variables and secrets, with Add variable.
- Keys use capital letters, digits and underscores, and don’t start with a digit:
DATABASE_URL,APP_ENV,S3_BUCKET. - Size: all of an app’s keys and values together can take up to 64 KB.
Secrets
- Write-only: once saved, a secret shows only as Secret, set. It’s never shown again in the dashboard. To change it, save the same key with a new value.
- Encrypted where we store it.
- Hidden in our output: build output and release command output show a secret’s value as
••••••••. - Not hidden in yours: what your app prints to its logs is shown as it is. Don’t print secrets.
If you remove a secret, you need its value again to add it back.
The password or token for a private image is kept as a secret too.
Applying your changes
Saving a variable doesn’t restart anything. Your app shows Changes not deployed yet, with Deploy changes.
Deploy changes makes a new release with your new variables and the image that’s running now. Any other deploy picks them up too.
Variables during builds
For an app that builds from GitHub, the Variables page has a During builds column. It’s off for every variable until you turn it on.
- A plain variable reaches the build as a build argument.
- A secret reaches it as a build secret, never written into the image.
See Deploys and releases for how to use them in your Dockerfile.
What the platform sets
Every instance gets these, and you can’t set or override them:
PORT: the web process’s port. Listen on it.- A set of variables that share one prefix, which the Variables page shows. Their names end in:
_APP_NAME: your app’s name;_PROCESS: the process, such asweborworker;_RELEASE: the release number;_INSTANCE_ID: this instance’s ID;_REGION: the region;_PRIVATE_IP: this instance’s private address.
Your own keys can’t start with that prefix.