ds_common_placeholder_py_lib.secret_store ========================================= .. py:module:: ds_common_placeholder_py_lib.secret_store .. autoapi-nested-parse:: **File:** ``secret_store.py`` **Region:** ``ds-common-placeholder-py-lib`` Description ----------- Reads secrets from ds-vault (``ds-vault-py-sdk``) for ``get_secret``. The package talks to the vault itself; there is nothing for a service to wire. Tests and examples replace the vault with :func:`ds_common_placeholder_py_lib.testing.fake_vault`. Configuration is the same as the dispatchers': ``VAULT_DATABASE_URL`` for the vault's Postgres table, and the usual AWS credentials for KMS. One client is created per process on first use; nothing is read at import time. The client keeps nothing between reads: the SDK's plaintext, decrypted data key, record, and SSM parameter caches are all disabled, so a resolved secret lives only in the execution that resolved it (contract §10) and a rotated secret is picked up on the next read. The cost is one vault query and one KMS decrypt per secret read. The SDK's caches are not thread-safe, so reads are serialised. The SDK does not check which tenant a key belongs to; ``get_secret`` does that before calling :func:`read_secret` (contract §7). Attributes ---------- .. autoapisummary:: ds_common_placeholder_py_lib.secret_store.VAULT_DSN_ENV Functions --------- .. autoapisummary:: ds_common_placeholder_py_lib.secret_store.read_secret Module Contents --------------- .. py:data:: VAULT_DSN_ENV :value: 'VAULT_DATABASE_URL' .. py:function:: read_secret(key: str) -> bytes | str | None Read one vault value. :param key: A vault path, already checked against the run's tenant. :returns: The stored bytes, or ``None`` if the vault has no such key. :raises RuntimeError: If ``VAULT_DATABASE_URL`` is not set. :raises Exception: Whatever the SDK raises for connection or decryption failures. ``get_secret`` turns it into ``secret_unavailable``.