Reputation: 107
How do I query just the value of a secret key from consul template ? From vault cli I would do
vault read -field=value secret/somekey
and it works fine. However, in the consul-template
{{secret "secret/somekey"}}
returns something like
{ 2592000 false map[value:11122222001040]
I can see it's outputting lease_duration etc along with the value. How do I get just the value in consul-template ?
Upvotes: 1
Views: 6611
Reputation: 619
In your template you will need to use:
{{with secret "secret/somekey"}}{{.Data.value}}{{end}}
In your config file you will also need a section for vault:
vault {
address = "https://vault.service.consul:8200"
token = "abcd1234"
}
or you could use the VAULT_TOKEN
environment variable.
Upvotes: 2