Skip to main content

yaml_secrets

Drop-in PyYAML replacement with secret substitution from HashiCorp Vault or OpenBao.

Install

cd configvault
python3 -m venv .venv
.venv/bin/pip install -e .

Usage

Replace import yaml with import yaml_secrets as yaml — nothing else changes.

import yaml_secrets as yaml  # or: import vault_yaml as yaml / openbao_yaml as yaml

with open("config.yaml") as f:
    cfg = yaml.safe_load(f)

Template syntax

Three equivalent ways to reference a secret:

# Jinja2 function (most common)
api_key: "{{ vault('secret/app/db', 'api_key') }}"

# YAML tag shortcut
api_key: !vault secret/app/db#api_key

# Jinja2 filter
api_key: "{{ 'secret/app/db#api_key' | vault }}"

Any Jinja2 expression works:

user: "{{ env.HOME }}/user"
region: "{{ region }}"

Configuration

Set environment variables before importing yaml_secrets:

# HashiCorp Vault
export VAULT_ADDR=https://vault.example.com:8200
export VAULT_TOKEN=hvs.xxxxx

# OpenBao (same API, different env prefix)
export OPENBAO_ADDR=https://openbao.example.com:8200
export OPENBAO_TOKEN=root-token-xxxxx

# Local mock (no server required — for dev/tests)
export BAO_MOCK_SECRETS=/path/to/mock-secrets.yaml

Mock file format:

secret/app/db:
  password: hunter2
  host: db.internal
secret/app/api:
  api_key: sk-live-123

Testing

.venv/bin/python -m pytest tests/ -v

Metadata

Release files for yaml-secrets 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaml-secrets 0.1.0
File Size Uploaded Provenance Actions
yaml_secrets-0.1.0.tar.gz 8.2 kB Without provenance Details for yaml_secrets-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yaml-secrets 0.1.0
File Interpreter ABI Platform Actions
yaml_secrets-0.1.0-py3-none-any.whl Python 3 none any Details for yaml_secrets-0.1.0-py3-none-any.whl

Total release size: 15.9 kB

Release files / yaml_secrets-0.1.0.tar.gz

Download URL yaml_secrets-0.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7cd869be117f8907a515e07139f193b6c4402551ae714631db421da74d5f662c
BLAKE2b-256 checksum
How to use checksums
ec11b1a76bab610b00d2c88d34ff4ff9d96b211f6a1d4f89f19cc8808c043a09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / yaml_secrets-0.1.0-py3-none-any.whl

Download URL yaml_secrets-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6782841cd27784e1cb5493aaea86b9cfc1048c508126fee379efd99485d1d5b7
BLAKE2b-256 checksum
How to use checksums
1d1178b9db412c836d737290988ce4f130c6072cce61a0de20ec9d03aecefff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for yaml-secrets 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page