»vault
Function
Secrets can be read from Vault and used within
your template as user variables. the vault
function is available only
within the default value of a user variable, allowing you to default a user
variable to a vault secret.
An example of using a v2 kv engine:
If you store a value in vault using vault kv put secret/hello foo=world
, you
can access it using the following:
which will assign local.foo
with the value "world"
An example of using a v1 kv engine:
If you store a value in vault using:
You can access it using the following:
This example accesses the Vault path secret/foo
and returns the value
stored at the key foo
, storing it as the local variable local.foo
.
If the Vault secret contains a highly sensitive value the local
block, not to be confused with
the locals
block, can be used to mark the value as sensitive.
and detailed documentation for usage of each of those variables can be found here.