Running your application
Environment variables
How the variables of an environment are kept in your own Secret Manager, and how to read and change them.
On this page
The environment variables of an environment are kept in the Secret Manager of your own Scaleway project: the one its application runs in. Brewless keeps their names and their revisions, never a value. When you ask to see or change the values, Brewless reads or writes them in your Secret Manager with the connection it already has and passes them on. They are not stored and not logged, and that someone looked at them is written to the audit trail.
From the command line
Fetch the variables of an environment into a file:
brewless env:pull production
This writes .env.production, with a first line that notes the revision you pulled. The file holds secrets: when git would not ignore it, as Laravel's own .gitignore does not for .env.staging, the client says so and offers to add it to .gitignore. Change it and push it back:
brewless env:push production
Both commands go through Brewless, so your machine needs no Scaleway key.
| Option | What it does |
|---|---|
--file= |
Another file than .env.<environment> |
--force |
On env:push: push without asking, also over a revision you did not pull |
--direct |
Read or write the variables in your Secret Manager straight from your machine, with a Scaleway key of your own. The values do not pass through Brewless |
Note
env:pushreplaces the variables of the environment with the contents of the file, comments included. If someone else saved after your last pull, the push is refused before it overwrites their revision. Variables the push would remove are named, and the client asks before it removes them.
With --direct the client takes the key from SCW_SECRET_KEY, or from the active profile of Scaleway's own client (scw init). The key needs to read and write Secret Manager in the project the application runs in.
From the console
On the Variables tab of an environment's Resources page you see the names, and you can set or remove a single variable.
Show values reads every variable from your Secret Manager as one dotenv file, which you can edit and save as a new revision. Saving replaces all variables with the file. When someone saved in between, saving is refused; load the newest revision and make your change again.
A value you set or save there passes through Brewless on its way to your Secret Manager. It is not stored and not logged. To keep values away from Brewless altogether, use brewless env:push --direct.
From brewless.yml
Plain values, such as a locale or a log level, can live in your brewless.yml under variables. A deploy writes them into a new revision before the build, next to the variables that are there. A name that looks like a secret is refused in the file: secrets stay with env:push. See brewless.yml.
A variable the file gives is marked Set in brewless.yml in the console. Changing or removing it here, or with a file that changes it, is refused: the next deploy would put the file's value back. Change it in the file and deploy.
Old versions
Your Secret Manager keeps at most 20 versions of the variables of one environment, and refuses the next. Before it writes a new version, Brewless removes the oldest versions that no longer matter: never the newest, and never one that a release of the last 30 of the environment ran with, so each of those can still be rolled back to. A removed version stays listed in the Scaleway console as scheduled for deletion until Scaleway purges it; Brewless no longer counts it and does not remove it again. Each removed version is in the audit trail as Removed an old version of the variables. When every version is still needed, the push or the save is refused with that reason; remove an old version in the Scaleway console and try again. The same goes before the backup runner writes the variables you take back from a backup.
When a change takes effect
Variables reach the containers with the next deploy. Until then the console shows that the newest revision is not live yet.
A container may still have plain variables that were set on it at Scaleway before Brewless kept its variables. A deploy takes off each one that the environment's variables also name, because the application would get that value and not the one you pushed. The plain variables the environment's variables do not name stay as they are.
When the secret was deleted at Scaleway
The variables are one secret in your Secret Manager. When someone deletes it there, Scaleway keeps it for a while so it can be restored, but nobody can read it. Changing a single variable then stops with a message that says so, because Brewless cannot read the other variables to keep them. You have two ways out:
- Restore the secret in the Scaleway console. Everything works again as before.
- Push the whole file again with
brewless env:push. Brewless makes a new secret under the same name, and its revisions count from 1 again.
Releases from before the deletion keep pointing at the deleted secret. Rolling back to one of them stops with a message that the secret was deleted, instead of running with the variables of the new secret.
Names
A name starts with a letter or an underscore and holds only letters, digits and underscores. A value has at most 16,000 characters.
What Brewless sets itself
A new environment is given the variables its resources bring: where its database, queue, bucket, cache and mailer are, and which store its cache and session use (see Cache). An environment that has variables already keeps every value it has, so nothing you set is replaced.
The name of the application and the sender of its mail are given too. A file you push or save often leaves them at Laravel's placeholders. A deploy hands the containers the name of the application in Brewless instead:
APP_NAMEthat is missing, empty orLaravel.MAIL_FROM_NAMEthat is missing, empty,Example,Laravelor${APP_NAME}. Containers do not fill in${...}, so the sender gets the application's name directly.MAIL_FROM_ADDRESSthat is missing or at anexample.com,example.orgorexample.netaddress, when Brewless set up mail for the environment: it becomeshello@the domain the environment sends from. Without that domain the address stays as it is.
With a bucket for files and bunny.net in front, a deploy also gives the containers AWS_URL with the files address, such as https://cdn.shop.example.eu, once that address answers with its certificate. Without AWS_URL of your own, Storage::disk('s3')->url() then names the files address instead of the bucket. storage.cdn: false in brewless.yml stops it.
With realtime in brewless.yml, a deploy gives the containers the keys of the realtime server (REVERB_APP_ID, REVERB_APP_KEY, REVERB_APP_SECRET) and, when your own variables leave them empty, REVERB_HOST, REVERB_PORT, REVERB_SCHEME and BROADCAST_CONNECTION. The keys are always the ones in your Secret Manager. The realtime container itself also gets its limits, REVERB_ALLOWED_ORIGINS and REVERB_APP_MAX_CONNECTIONS, where your own variables leave them empty. See What your application gets.
Every deploy gives every container BREWLESS_ENVIRONMENT, the id of its environment. The Rust crate brewless-laravel (from 0.4) signs the jobs your application queues with a key of that environment, so a job signed in one environment never runs in another, even when both have the same APP_KEY. It is the one variable in this section that a value of your own does not replace.
Your file stays as you pushed it, and a value of your own in it always wins.
There is one name you cannot use: BREWLESS_OPS_SECRET. It is the secret of the machine entrance (/_ops/*), through which Brewless runs your release commands, your schedule and your queue. Brewless gives it only to the containers that do that work, the release container and the worker; the container that serves your visitors never has it, so its machine entrance stays shut. The console and brewless env:push refuse a file or a variable with that name. Should it be in your Secret Manager anyway, written there by hand, a deploy leaves it out of what the containers get and takes it off a container that had it.
Every environment has an ops secret of its own, in your own Secret Manager under <application>-<environment>-ops-secret: whoever holds the one of a test environment holds nothing of production. Brewless makes it when it sets the environment up. For containers you brought yourself it is made with the first deploy after the environment's variables are kept through Brewless (brewless env:push), and that deploy gives it to the release container, the worker and the crons. The secret of another environment is never used in its place.