Variables and secrets

Environment variable is a text variable of the operating system (in our case, the container), storing some information - for example, data about system settings, tokens, passwords, etc. Amverum Cloud allows you to create and use environment variables and secrets.

Important

You need to restart the containers for the variables to apply. Environment variables are not available during the build phase!

Adding a variable or secret

Adding occurs in the «Variables» section:

python_config

To add a variable/secret, you need to click on the «Create variable» button and fill out the pop-up creation form:

python_config

Where:

  • Name - the name of the created variable/secret by which it is available in the system.

  • Value - the required value that this variable/secret should store.

Accessing variables

Once an environment variable is added, it will be readable as follows (Python example):

import os

my_var = os.environ["MY_VAR"]

Instead of «MY_VAR» you need to substitute the name of the environment variable or secret that was added through the web interface.

AMVERUM variable

If an application needs to distinguish in which environment it is running: Amverum or, for example, locally on the developer’s computer, you can use the AMVERUM environment variable. In the Amverum environment, this variable is set and has a value of 1. So, to understand in Python code whether the program is running locally or in Amverum, it is enough to execute:

import os

amverum_var = os.environ["MY_VAR"]
if amverum_var == 1:
    print("I work in the Amverum cloud")
else:
    print("I work locally")

Difference between secrets and environment variables

The difference between secrets and regular environment variables is that regular environment variables are stored in plain text in the database, while secrets are stored in a separate secrets store, and only a reference to this secret is stored in the database. Secrets are suitable for storing confidential information such as tokens and passwords.