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.1

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.1
File Size Uploaded Provenance Actions
yaml_secrets-0.1.1.tar.gz 10.4 kB Without provenance Details for yaml_secrets-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 19.8 kB

Release files / yaml_secrets-0.1.1.tar.gz

Download URL yaml_secrets-0.1.1.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
30f1e3b49dd07098087cef7d4b39ab9e3181ee9a572b4a2ebb5295d7cbddd9bb
BLAKE2b-256 checksum
How to use checksums
0e73224dad46db7d0734df6689dadc3df68d90e8d0c487a2f546a51ead0116cc
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.1-py3-none-any.whl

Download URL yaml_secrets-0.1.1-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59f59107d4dc201f5d2def301c892f80f7368926dc401c0e05eab151febe15e8
BLAKE2b-256 checksum
How to use checksums
9fc31d7ec5476bb0baa0db05934783c0634ad4f814b07dac73e7f7f4f377810f
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.1

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.1 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