Skip to content

Link config files to the vault

vaultfold link writes a vault:// reference into an existing project file in place of a plaintext value. Comments, ordering and formatting stay as they were, and the file keeps its mode.

  • An entry in the vault to point at (see store and read).
  • The file must already exist. link checks the reference syntax but does not resolve it, so it unlocks nothing and never writes a secret.

For an .env file the second argument is the variable name. For JSON, YAML and TOML it is a dot path.

Terminal window
vaultfold link .env DB_PASS vault://app/db#password
vaultfold link config.json database.password vault://app/db#password
vaultfold link config.yaml database.password vault://app/db#password
vaultfold link config.toml database.password vault://app/db#password

Each command prints the fully qualified reference it wrote, for example vault://myapp/app/db#password, with the vault name filled in.

A linked .env works with run. Structured files work as templates for inject, which keeps the format and fills the reference in on its way out.

Terminal window
vaultfold run --env-file .env -- npm start
vaultfold inject -i config.yaml

link refuses a third argument that is not a reference, and a file that does not exist. To store a plaintext value, add it with vaultfold add first and link its reference.

Terminal window
vaultfold add app/db#password --stdin
vaultfold link .env DB_PASS vault://app/db#password
  • Vault commands start the agent daemon and unlock once; link itself does not unlock anything, but the run or inject that resolves the reference does. Set VAULTFOLD_NO_AGENT=1 to skip the daemon and unlock in-process for that command only.
  • A reference to an entry or field that was later removed fails when it is resolved, not when it is linked.
  • inject to standard output prints real values; do not redirect it to a file you will commit.