Environment Variable
Qovery makes Environment Variables available to your services at runtime, as well as during builds and deploys.
Here is a short video to show how to use environment variables.
Levels
There are four levels of Environment Variables. Each type differs in scope - you can create variables bound to application, environment, or project.
Scope | Level | Description |
---|---|---|
BUILT_IN | 1 | Automatically generated variables based on your configuration (e.g., requested databases) propagated to all projects, environments, and applications |
PROJECT | 2 | Variables at the project level are shared across all environments and all applications of the project |
ENVIRONMENT | 3 | Variables at the environment level are shared across all applications of the project in one, given environment |
APPLICATION | 4 | Variables available for one application in one environment |
Built-in variables
By default, every environment contains built-in variables:
Name | Description |
---|---|
QOVERY_PROJECT_ID | Current project ID |
QOVERY_ENVIRONMENT_ID | Current environment ID |
QOVERY_APPLICATION_ID | Current application ID |
Additional built-in variables
For any added service (database, broker, storage), your application receives additional built-in variables. These can be used, for example, to connect to the database.
Naming Convention:
We use the following naming convention for additional built-in variables:
QOVERY_<SERVICE_TYPE>_<SERVICE_ID>_<SPEC>
Additional Rules
- Environment variable keys should use only alphanumeric characters and the underscore character (_) to ensure they are accessible from all programming languages. Environment variable keys should not include the hyphen character.
- Environment variable keys should not begin with a double underscore (__).
- An environment variable’s key should not begin with QOVERY_ unless it is set by the Qovery platform itself.
Create an Environment Variable
Navigate to Console
Select your project, environment and application
Select
Environment Variables
tab in the left panel and clickCreate
button:Select the name and value of your new environment variable
Scopes
Delete an Environment Variable
Navigate to Console
Select your project, environment and application
Select the
Environment Variables
tab in the left panelSelect variable you want to delete and click the
Delete
button:
Update an Environment Variable
Navigate to Console
Select your project, environment and application
Select the
Environment Variables
tab in the left panelSelect variable you want to update and click the
Edit
button:Update the variable in the popup window:
Override Environment Variable
If you want to override a value of an environment variable, follow those steps:
Navigate to Console
Select your project, environment and application
Select the
Environment Variables
tab in the left panelSelect variable you want to override and click the
Override
button:Override the variable in the popup window:
Alias Environment Variable
You can create an alias for the existing environment variable.
Let's suppose that your application requires a DATABASE_URL
variable. Qovery provides your application with the QOVERY_DATABASE_MY_POSTGRESQL_3498225_URL
variable with a database password.
Instead of copy-pasting its value, you can create an alias to QOVERY_DATABASE_MY_POSTGRESQL_3498225_URL
.
Navigate to Console
Select your project, environment and application
Select the
Environment Variables
tab in the left panelSelect variable you want to alias and click the
Alias
button:Alias the variable in the popup window:
Import environment variables
You can add a set of environment variables into Qovery by importing an .env
file. The .env
file contains a list of your environment variables, in a MY_KEY = VALUE
format.
To import environment variables into your Qovery environment, follow the steps below.
On an application page, click on the
Environment variable
tabs >Import
button.Drag & Drop the
.env
file into the modal, or click on the interface to open the file explorer.The file is loaded and a new modal is displayed, where you can configure the import of your variables.
Overwrites variables
When this option is enabled, if an existing variable and an imported variable share the same name, the existing value will be overwritten by the imported one. If the option is disabled, the imported value will be ignored. However, to avoid conflicts in the architecture of your environment variables, some of them will intentionally not be imported. To understand how we handle conflicts, please take a look to the Importation conflicts section.
Configure variables import
On this modal, you can define for each variable the following parameters:
- name: upate variable name
- Value: update variable value
- Scope: Specify the scope in which you want to import the variable
- Secret: Specify if this value is considered as a secret or not
Preset variables
To help you import a large number of variables quickly, you can predefine scope and secret settings. This will change the scope and secret value of all listed variables. If the secret and scope of one or more specific variables are subsequently updated, this will not change the predefined setting.
When you have finished the configuration, click on the
Import
button.A pop-up message is displayed to inform you that your environment variables have been imported.
Importation conflicts
To avoid conflicts between already existing and imported environment variables, some of them will not be imported, even if the overwrite option is activated. The different cases are described below.
Imported variable has same name as BUILT_IN variable
Type | Name | Value | Scope |
---|---|---|---|
Existing variables | |||
VALUE | MY_VAR | 42 | Built_in |
Variables to import | |||
VALUE | MY_VAR | 10 | Application |
Built_in environment variables are generated and managed by Qovery and will not be overwritten, even if the overwriting
option is activated.
Imported variable has same name as an existing ALIAS
Type | Name | Value | Scope |
---|---|---|---|
Existing variables | |||
VALUE | MY_VAR | 42 | Environment |
ALIAS | MY_VAR_ALIAS | MY_VAR | Application |
Variables to import | |||
VALUE | MY_VAR_ALIAS | 10 | Application |
The value cannot be rewritten because the link between the original variable and the alias would be lost.
Imported variable has same name as an existing secret (or vice versa)
Type | Name | Value | Scope | Secret |
---|---|---|---|---|
Existing variables | ||||
VALUE | MY_VAR | 1 | Application | Ye |
Variables to import | ||||
VALUE | MY_VAR | 2 | Application | No |
The value cannot be imported because this will overwrite the existing secret.
Overwriting and limitations
Some overwriting cases are not supported for now. They are summarized in the following table.
Existing variable scope | Imported variable scope | Supported |
---|---|---|
PROJECT | PROJECT / ENVIRONMENT / APPLICATION | YES |
ENVIRONMENT | PROJECT | NO |
ENVIRONMENT | ENVIRONMENT / APPLICATION | YES |
APPLICATION | PROJECT / ENVIRONMENT | NO |
APPLICATION | APPLICATION | YES |