Consul-template's "env" function not available in Vault Agent template?

I’m attempting to leverage Vault Agent templates for dynamic configuration. One thing that I am trying to do in the template is to read an environment variable into said templates. In this case, I have an environment variable called “ENVIRONMENT” that is set to “test”. I can confirm it’s set in my terminal with a simple echo $ENVIRONMENT. However, I am unable to inject that value into a template. I have tried the following ways:

  • {{ $ENV_NAME := env “ENVIRONMENT” }}{{ $ENV_NAME }}
  • {{ $ENV_NAME := env “ENVIRONMENT” }}{{ printf $ENV_NAME }}
  • {{ env “ENVIRONMENT” }}
  • {{ printf (env “ENVIRONMENT”) }}
  • {{ printf “%s” (env “ENVIRONMENT”) }}

Additionally, if I do something like {{ or (env “ENVIRONMENT”) “dummy-string” }}, then the template renders “dummy-string”, revealing that it interprets env “ENVIRONMENT” as empty. Documentation on the “env” function in consul-template isn’t robust, so maybe I’m doing something obviously wrong, but I’m at a loss. Is it simply that the env function isn’t available to the Vault Agent implementation of the template engine? Or is something else afoot here?