env Block
Placement | job -> group -> task -> env |
The env
block configures a list of environment variables to populate the
task's environment before starting.
env
Parameters
The "parameters" for the env
block can be any key-value. The keys and values
are both of type string
, but they can be specified as other types. They will
automatically be converted to strings. Invalid characters such as dashes (-
)
will be converted to underscores.
env
Examples
The following examples only show the env
blocks. Remember that the
env
block is only valid in the placements listed above.
Coercion
This example shows the different ways to specify key-value pairs. Internally, these values will be stored as their string representation. No type information is preserved.
Interpolation
This example shows using Nomad interpolation to populate environment variables.
Environment variables with dots
Environment variables that aren't valid HCLv2 identifiers, like ones containing .
, require an alternative map assignment syntax.
Dynamic Environment Variables
Nomad also supports populating dynamic environment variables from data stored in
HashiCorp Consul and Vault. To use this feature please see the documentation on
the template
block.