Customize Vault secret environment variable names
mainYou can control how Vault secrets are mapped to environment variables using several methods:
- Disable path prefixing: Set
no_prefix = truein thesecretblock. - Apply key transformations: Use the
-upcaseflag to uppercase all keys. - Use format strings: Use the
formatoption in thesecretblock. The{{ key }}placeholder is replaced by the key name. This is processed by the Go formatter. - Per-key configuration: Define specific
keyblocks within asecretblock to apply uniqueformatornamesettings to individual keys.
Note: Per-key format only works if there is no format defined at the secret level.
secret {
path = "secret/passwords"
format = "creds_{{ key }}"
key {
name = "username"
format = "readonly_user_{{ key }}"
}
key {
name = "password"
format = "custom_prefix_{{ key }}"
}
}