confd configuration with HashiCorp Vault KV v2

794 Views Asked by At

I'm creating a Vault Dev Server with sudo vault server -dev and putting a simple KV v2 secret with:

vault kv put secret/database url=db.example.com

I wish confd pick that value whenever value is changed in KV store in Vault. But I'm getting the error:

FATAL template: env.tmpl:2:9: executing "env.tmpl" at <getv "database/url">: error calling getv: key does not exist: database/url

When I run:

sudo confd --onetime --log-level debug --backend vault --auth-type token --auth-token s.ossadqwsssssssafadsd --node http://127.0.0.1:8200 -prefix='/secret'

My /etc/confd/templates/env.tmpl is:

[myconfig]
url = {{ getv "database/url" }}

and /etc/confd/conf.d/myconfig.toml is

[template]
src = "env.tmpl"
dest = "env.conf"
keys = [
   "secret/database"
]

Any help would be appreciated.

1

There are 1 best solutions below

2
sethvargo On

KV v2 has data in a /data prefix. You need to change your path to be getv "data/database/url" in the config template or change prefix to /secret/data in the flag.