environment-variablesconsulconsul-templateconsul-kv

Assigning Environment Variables from Consul KV using consul-template


I am very new to consul. I just want to load my environment variables from consul kv using consul-template. I have an consul kv entry having key "iamdbusername". I want to assign its value in an environment variable IAM_DB_USER with the help of consul-template. My application is using the environment variable IAM_DB_USER for getting the database user name.

Any clue in this will be very helpful for me.

Thanks!!!


Solution

  • envconsul can be used to launch a subprocess with environment variables that are populated from Consul.

    https://stackoverflow.com/a/67888502/12384224 provides an example of launching a process with envconsul, as well as with an additional tool called Teller.