HashiCorp Vault and OpenBao¶
Reads from the KV secrets engine of HashiCorp Vault or OpenBao, whose API is compatible.
vault:
address: https://vault.example.com # default: $VAULT_ADDR
mount: secret # default: secret
components:
api:
env_file: .env
vars:
DB_USER: "{{vault:app/db#user}}" # secret/app/db, field "user"
DB_PASS: "{{vault:app/db#password|urlencode}}"
PINNED: "{{vault:app/db:3#password}}" # version 3
OTHER_MOUNT: "{{vault:/kv/team/api#key}}" # mount "kv"
- Path: without a leading
/, the path is under the configuredmount(secretby default). With a leading/, the first segment is the mount, as in/kv/team/api. For a nested mount such asteam/kv, setmount:. - Fields: a Vault secret holds several fields.
#keypicks one; without it you get the whole secret as a JSON object. - Versions:
:3reads version 3 (KV v2). Without a version you get the latest. - KV v1: set
kv_version: 1for mounts using the version 1 engine.
Signing in¶
envhaul uses the same token the vault CLI does, in this order:
- the environment variable named by
token_env, if set; VAULT_TOKEN;~/.vault-token, whichvault loginwrites.
The address comes from address or VAULT_ADDR. For a server with a
private CA, set VAULT_CACERT to the CA certificate file.
Profiles and namespaces¶
@name selects a profile from the vault: block, whose settings override
the defaults. Use this for a second Vault server or different credentials:
vault:
address: https://vault.example.com
profiles:
prod:
address: https://vault.prod.example.com
token_env: VAULT_PROD_TOKEN
team:
namespace: team-a
If @name doesn't match a profile, it's used as the namespace (Vault
Enterprise and OpenBao), so {{vault:app/db#key@team-a}} works without any
profile. namespace: and VAULT_NAMESPACE set a default namespace.
Settings¶
| Setting | Default | Description |
|---|---|---|
address |
$VAULT_ADDR |
Server address |
namespace |
$VAULT_NAMESPACE |
Namespace (Enterprise, OpenBao) |
mount |
secret |
KV mount for paths without a leading / |
kv_version |
2 |
KV engine version, 1 or 2 |
token_env |
Environment variable holding the token |
API usage and permissions¶
envhaul reads with GET /v1/<mount>/data/<path> (KV v2) or
GET /v1/<mount>/<path> (KV v1), running up to 8 reads at once; Vault has
no batch read. A policy that allows envhaul to read app/* in the secret
mount:
A secret that doesn't exist, or a deleted version, counts as missing (see
Missing values). A permission error stops the
run and suggests vault login.