Skip to content

get_env

unitstack

Usage

get_env(name: string, [default: string]) --> string

get_env returns the value of the environment variable name. If the variable is not set, it returns default, and without a default it fails.

Parameters

namestring

Name of the environment variable.

defaultoptional(string)

Value to return when the variable is not set. Without it, an unset variable is an error.

Examples

Without default, get_env fails when the variable is not set.

terragrunt.hcl
inputs = {
image_tag = get_env("IMAGE_TAG")
}

With default, get_env returns it when the variable is not set.

terragrunt.hcl
inputs = {
image_tag = get_env("IMAGE_TAG", "latest")
}