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.

ScopeLevelDescription
BUILT_IN1Automatically generated variables based on your configuration (e.g., requested databases) propagated to all projects, environments, and applications
PROJECT2Variables at the project level are shared across all environments and all applications of the project
ENVIRONMENT3Variables at the environment level are shared across all applications of the project in one, given environment
APPLICATION4Variables available for one application in one environment

Built-in variables

By default, every environment contains built-in variables:

NameDescription
QOVERY_PROJECT_IDCurrent project ID
QOVERY_ENVIRONMENT_IDCurrent environment ID
QOVERY_APPLICATION_IDCurrent 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

  1. Navigate to Console

  2. Select your project, environment and application

  3. Select Environment Variables tab in the left panel and click Create button:

    Variables

  4. Select the name and value of your new environment variable

    Variables

    Scopes

Delete an Environment Variable

  1. Navigate to Console

  2. Select your project, environment and application

  3. Select the Environment Variables tab in the left panel

    Variables

  4. Select variable you want to delete and click the Delete button:

    Delete Variables

Update an Environment Variable

  1. Navigate to Console

  2. Select your project, environment and application

  3. Select the Environment Variables tab in the left panel

    Variables

  4. Select variable you want to update and click the Edit button:

    Update Variables

  5. Update the variable in the popup window:

    Update Variables

Override Environment Variable

If you want to override a value of an environment variable, follow those steps:

  1. Navigate to Console

  2. Select your project, environment and application

  3. Select the Environment Variables tab in the left panel

    Variables

  4. Select variable you want to override and click the Override button:

    Override Variables

  5. Override the variable in the popup window:

    Override Variables

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.

  1. Navigate to Console

  2. Select your project, environment and application

  3. Select the Environment Variables tab in the left panel

    Variables

  4. Select variable you want to alias and click the Alias button:

    ALias Variables

  5. Alias the variable in the popup window:

    Alias Variables

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.

  1. On an application page, click on the Environment variable tabs > Import button.

    Import button

  2. Drag & Drop the .env file into the modal, or click on the interface to open the file explorer.

    Loading interface

  3. The file is loaded and a new modal is displayed, where you can configure the import of your variables.

    Import configuration

    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.

  4. When you have finished the configuration, click on the Import button.

  5. A pop-up message is displayed to inform you that your environment variables have been imported.

    Import button

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

TypeNameValueScope
Existing variables
VALUEMY_VAR42Built_in
Variables to import
VALUEMY_VAR10Application

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

TypeNameValueScope
Existing variables
VALUEMY_VAR42Environment
ALIASMY_VAR_ALIASMY_VARApplication
Variables to import
VALUEMY_VAR_ALIAS10Application

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)

TypeNameValueScopeSecret
Existing variables
VALUEMY_VAR1ApplicationYe
Variables to import
VALUEMY_VAR2ApplicationNo

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 scopeImported variable scopeSupported
PROJECTPROJECT / ENVIRONMENT / APPLICATIONYES
ENVIRONMENTPROJECTNO
ENVIRONMENTENVIRONMENT / APPLICATIONYES
APPLICATIONPROJECT / ENVIRONMENTNO
APPLICATIONAPPLICATIONYES