ds_common_placeholder_py_lib.secret_store¶
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
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 read_secret() (contract §7).
Attributes¶
Functions¶
|
Read one vault value. |
Module Contents¶
- ds_common_placeholder_py_lib.secret_store.VAULT_DSN_ENV = 'VAULT_DATABASE_URL'¶
- ds_common_placeholder_py_lib.secret_store.read_secret(key: str) bytes | str | None[source]¶
Read one vault value.
- Parameters:
key – A vault path, already checked against the run’s tenant.
- Returns:
The stored bytes, or
Noneif the vault has no such key.- Raises:
RuntimeError – If
VAULT_DATABASE_URLis not set.Exception – Whatever the SDK raises for connection or decryption failures.
get_secretturns it intosecret_unavailable.