It is already possible to use the values of environment variables through env var in HCL. This has a limited use, though, since env var values exist outside the evaluation context and can not be easily filtered/mutated.
Design
Env variables should be available in the evaluation context under .env root key.
To minimize the risk of exposing all environment variables to potentially malicious plugins, we introduce a global configuration argument expose_env_vars_with_prefix.
If expose_env_vars_with_prefix is set, only the env vars that have the prefix in their name are available in the context under .env key.
If expose_env_vars_with_prefix is null, use the default value.
If expose_env_vars_with_prefix is an empty string, all env variables are exposed in the context
Example:
fabric {
expose_env_vars_with_prefix = "FABRIC_" # default value
}
document "test" {
content text {
value = "All env vars in the context: {{ .env | toPrettyJson }}"
}
}
Background
It is already possible to use the values of environment variables through
env
var in HCL. This has a limited use, though, since env var values exist outside the evaluation context and can not be easily filtered/mutated.Design
Env variables should be available in the evaluation context under
.env
root key.To minimize the risk of exposing all environment variables to potentially malicious plugins, we introduce a global configuration argument
expose_env_vars_with_prefix
.If
expose_env_vars_with_prefix
is set, only the env vars that have the prefix in their name are available in the context under.env
key.If
expose_env_vars_with_prefix
is null, use the default value. Ifexpose_env_vars_with_prefix
is an empty string, all env variables are exposed in the contextExample: