Prompt

How do I use a vault for local dev secrets?

Technology / Cybersecurity1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

A good pattern is to use a secrets manager as the source of truth, then inject secrets into your local app at runtime instead of hardcoding them in .env files.

Common local-dev approaches

1) Pull secrets from the vault when you start the app

Your app start command fetches secrets and exports them as environment variables.

Example flow:

  • authenticate to vault
  • read secrets for your dev environment
  • load them into env vars
  • start the app

Example with Vault CLI:

vault login
export DB_PASSWORD="$(vault kv get -field=password secret/myapp/dev)"
export API_KEY="$(vault kv get -field=api_key secret/myapp/dev)"
npm run dev

2) Use a wrapper script

Create a script like dev.sh that fetches secrets and then launches your app.

#!/usr/bin/env bash
set -euo pipefail

export $(vault kv get -format=json secret/myapp/dev | jq -r '.data.data | to_entries | map("\(.key)=\(.value|tostring)") | .[]')
npm run dev

This is convenient for teams, but be careful with quoting and multiline values.

3) Use Vault Agent or a sidecar to render a .env file

A safer and more flexible option is to have Vault Agent authenticate and template secrets into a local file.

Example template:

template {
  source      = "dev.env.tpl"
  destination = ".env.local"
}

Template:

DB_PASSWORD={{ with secret "secret/myapp/dev" }}{{ .Data.data.password }}{{ end }}
API_KEY={{ with secret "secret/myapp/dev" }}{{ .Data.data.api_key }}{{ end }}

Then your app loads .env.local as usual.

This is often the best choice if:

  • you have many secrets
  • values change often
  • you want to avoid manually exporting variables

Recommended workflow for local dev

  1. Store dev secrets in a dedicated path

    • secret/myapp/dev
    • keep it separate from prod
  2. Use short-lived auth

    • Vault token from OIDC, LDAP, or AppRole
    • avoid long-lived shared tokens
  3. Inject secrets at startup

    • via env vars or generated .env.local
  4. Never commit secrets

    • add .env.local to .gitignore
  5. Rotate and scope tightly

    • dev app should only read the dev secret path

Example setup with Vault CLI

vault kv put secret/myapp/dev DB_PASSWORD=devpass API_KEY=devkey
vault kv get secret/myapp/dev

Then run:

vault login
source <(vault kv get -format=json secret/myapp/dev \
  | jq -r '.data.data | to_entries[] | "export \(.key)=\(.value|tostring)"')
npm run dev

Best practices

  • Use separate namespaces/paths for dev, staging, prod
  • Prefer short-lived credentials over static secret values where possible
  • Use least privilege policies
  • Avoid printing secrets in logs
  • Don’t use vault as a replacement for config files that don’t need secrecy

If you want, I can show you:

  • a Docker Compose setup with Vault
  • a Node/Python/Go example
  • a Vault Agent template for .env.local

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.