Work with Environment Variables
Learn how to work with Environment Variables for Containers in Humanitec.
Environment Variables are key-value pairs that are provided by the environment that a process runs in. They are a very common and practical way of configuring containers. Environment Variables can be easily changed and do not require updates to the file systems as with Configuration Files.
Sometimes the value of some configuration will change depending on the Environment that a workload is deployed into. For example, you may want your workload to connect to a different database in a development than in a production environment. To allow for this, Humanitec provides placeholders that can be inserted into the variable values.
Placeholders are of the form
${...}
where the content is a placeholder path. Any number of placeholders can be included in the value of a variable. For example:Hello ${values.PLACEHOLDER_EXAMPLE}!
Will resolve the shared value
PLACEHOLDER_EXAMPLE
at deployment time and insert the value into the string above.Sometimes the value of an environment variable contains a sensitive value that should not be visible to other developers. An example of this would be database credentials. Secrets should be stored as shared Values and Secrets and then referenced in an Environment Variable using a placeholder. If the content of a placeholder is a secret, Humanitec will automatically convert the entire value into a secret.
Environment Variables are added as "Variables" to Containers inside a Workload.
UI
CLI
API
- 1.
- 2.
- 3.Choose the container in the workload you want to update.
- 4.Select Add Variables and enter:
- the name of the Environment Variable you want to make available to the Container. The name must only consist of alphanumeric characters,
-
,_
or.
. - the value for the Environment Variable including any Placeholders you require. Typing Enter will save the value and provide a new row to enter further variables.

Steps for adding Environment Variables to a Container in a Workload.
Typing Enter or Tab moves you to the next field
You can enter multi-line values by using Shift + Enter to add new lines. Copy and pasting multi-line values also works.
Adding Environment Variables involves adding a property to the
variables
section of the container
object in the spec
section of a module
in a Deployment Set. See Deployment Deltas in the API Documentation for more details of how this can be done.Environment Variables are added as "Variables" to Containers inside a Workload.
UI
CLI
API
- 1.
- 2.
- 3.Choose the container in the workload you want to update.
- 4.Click on the pencil icon to edit the Environment Variable.
- 5.Click the bin icon to delete the Environment Variable.

Steps to Update or Delete an Environment Variable for a Container in a Workload.
Updating or deleting Environment Variables involves updating the
variables
section of the container
object in the spec
section of a module
in a Deployment Set. See Deployment Deltas in the API Documentation for more details of how this can be done.Last modified 26d ago