Ravindra BagaleCourses & study guides मराठी

Chapter 94: HashiCorp Vault and Secrets Management

DevOps

94.5 KV v2 — mounts, data paths and metadata paths

Story (fictional teaching scenario). In a fictional Surat app team, Omar from Doha writes policy for secret/shop and gets denied. Kavya checks that the engine is KV v2: its API uses data and metadata subpaths.

KV v2 — mounts, data paths and metadata paths
KV v2 — mounts, data paths and metadata paths

Why

CLI convenience hides path translation. Policies and direct API clients must use the actual engine paths.

What

  • Secrets engine implements operations such as key/value storage or credential generation.
  • Mount is the path where an engine is enabled, such as secret/.
  • KV v2 is versioned key/value storage.
  • Data path reads/writes the value. Metadata path reads version information or lists key names.
  • A logical CLI path is not always the raw API policy path.

How

  1. Identify the mount and engine version.

  2. Use -mount for CLI clarity.

  3. Write policies against the documented v2 API paths.

Example 1: Write one fake field

  1. Read the command or request.
vault kv put -mount=secret shop label=DEMO_ONLY
  1. Read the result.

Output (illustrative; NOT executed against Vault)

Key: version
Value: 1
  1. Line by line: put creates a new secret version. label is a harmless demonstration field, not a credential. Existing KV data may be replaced by a put unless the intended whole value is supplied; use the documented patch operation when appropriate.

Example 2: Read via CLI

  1. Read the command or request.
vault kv get -mount=secret -field=label shop
  1. Read the result.

Output (illustrative; NOT executed against Vault)

DEMO_ONLY
  1. Line by line: -field selects one value instead of the full response. It still prints that value. Do not use this display pattern for a real secret in logs or recorded terminals.

Example 3: Raw API path and JSON shape

  1. Read the command or request.
GET /v1/secret/data/shop
  1. Read the result.

Output (illustrative; NOT executed against Vault)

{"data":{"data":{"label":"DEMO_ONLY"},"metadata":{"version":1}}}
  1. Line by line: The first data wraps the engine response. The second data contains user fields. metadata.version describes the stored version. Reading metadata alone uses /v1/secret/metadata/shop; listing uses LIST on a metadata prefix. No actual API request was made.

Ravindra Bagale's Tip

For KV v2, data and metadata are different policy paths.

Did you understand? Let us try it once more.