Gyro Containers: environment variables and secrets (passwords, API keys)
1. Variable or secret?
| Environment variable | Secret | |
|---|---|---|
| What for? | Settings: MODE=prod, LOG_LEVEL=info |
Passwords, API keys, tokens |
| Visible in the panel? | Yes, with values | No: only the name is shown, the value is never shown again |
| Storage | Part of the service revision | Stored encrypted |
| To the application | Given as an environment variable | Given as an environment variable |
| In revision history | Yes (comes back on rollback) | No (kept as is on rollback) |
Put passwords and keys in secrets, not environment variables. Variables are visible in the revision history and API responses.
Rules: A variable name consists of letters, digits and _. Names starting with GYRO_ and other prefixes reserved by the platform cannot be used; the panel then says "Invalid variable name/value".
2. Editing environment variables
- Open Services in your environment and click your service.
- In the Environment variables section press Edit.
- Write
KEY=VALUEon each line. Anything not in the list is deleted; the list represents the full set. - Press Save. The message "Variables saved, the service is restarting." appears.
A variable change creates a new revision and the service restarts in turn without downtime. If you roll back, the variables return to their old values.
# Add/update on top of existing ones
gyro container env set 12345 api --data '{"set":{"MODE":"prod","LOG_LEVEL":"info"}}'
# Remove a variable
gyro container env set 12345 api --unset LOG_LEVEL
# Replace the whole set with this list
gyro container env set 12345 api --replace 1 --data '{"set":{"MODE":"prod"}}'
3. Adding and deleting secrets
- On the service page press Add in the Secrets section.
- Enter a Name (for example
DB_PASSWORD) and a Value and save. You see "Secret saved, the service is restarting." - The value is stored encrypted; the panel and API show only the name. To change a value save it again under the same name.
- To delete, use the delete button next to the name ("Delete {name}? The service restarts").
# Use stdin so the value does not end up in your shell history
echo '{"set":{"DB_PASSWORD":"very-secret"}}' | gyro container secret set 12345 api --data @-
gyro container secret delete 12345 api --keys DB_PASSWORD
Adding or deleting a secret restarts the service; replicas are renewed in turn so there is no downtime. Secrets do not create a revision and stay as they are on rollback.
4. Using them in your application
Both kinds reach your application as environment variables:
import os
db_password = os.environ["DB_PASSWORD"] # secret
mode = os.environ.get("MODE", "dev") # variable
5. Frequently asked questions
I forgot a secret's value; how can I see it?
You cannot; the value is never shown again. Take it from your source or password manager and save it again.
Can the same name be both a variable and a secret?
Do not give the same name as both a variable and a secret; which one applies would be unclear. Use only a secret for values like passwords.
How are secrets managed in Terraform?
The secrets field is write-only; Terraform state does not read the value back (API, CLI and Terraform).
Can I provide a file (certificate, JSON key)?
Files cannot be mounted. Put the content (for example base64) in a secret and write it to a file in your application, or read it from Object Storage.
Next step
Thanks for your feedback!