Config utility library to fetch configuration from AWS SSM/Secrets Manager and .env files
Project description
Toktak Config Fetcher
Description
A Python utility library for loading configuration from AWS Systems Manager (SSM) Parameter Store, AWS Secrets Manager, and .env files. Provides a unified interface with caching and TTL support.
Installation
From PyPI
pip install toktak-config-fetcher
From source
git clone <repository-url>
cd toktak_config_fetcher
pip install .
Usage
from toktak_config_fetcher import preload_config, get_config, get_config_int
# Preload all config from .env and AWS (optional)
preload_config() # Loads all keys from .env file
# Or preload specific keys
preload_config(["DATABASE_URL", "PORT", "API_KEY"])
# Get string config (fetches from AWS if not cached, falls back to .env)
database_url = get_config("DATABASE_URL", default_value="sqlite:///default.db")
# Get integer config
port = get_config_int("PORT", default_value=8080)
Logic Flow
- Load all config from
.envfile. - Fetch values from AWS for the keys found in
.envfile (if not in local mode). - The values from AWS are stored in a cache.
- The cache has a
TTL(Time to Live) of 300 seconds. If the TTL expires, values will be fetched from AWS again. - The secret key must start with
SECRET_prefix. - In local mode (
DEPLOY_ENV=local), only.envfile values are used. - In non-local mode, AWS values take priority over
.envfile values.
Environment Variables
Required Configuration
REGION: The AWS Region. Default value isap-northeast-2ORG: Organization name. Default value isvodaplayDEPLOY_ENV: The AWS Environment. Possible values:local,dev,stg,prod. Default islocalAPP_NAMESPACE: The group/namespace of this project. The config utils will combineORG,DEPLOY_ENV, andAPP_NAMESPACEto form the prefix for env key when getting config value from AWS
AWS Configuration
Ensure your AWS credentials are configured via:
- AWS credentials file (
~/.aws/credentials) - Environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - IAM role (when running on EC2/ECS/Lambda)
AWS Path Structure
- SSM Parameters:
/{ORG}/{DEPLOY_ENV}/{APP_NAMESPACE}/{key}or/{ORG}/{DEPLOY_ENV}/COMMON/{key} - Secrets:
/{ORG}/{DEPLOY_ENV}/{SECRET_key}
Development
# Install with development dependencies
pip install -e ".[dev,test,linting]"
# Run tests
pytest
# Run linting
flake8 toktak_config_fetcher
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toktak_config_fetcher-1.0.1.tar.gz.
File metadata
- Download URL: toktak_config_fetcher-1.0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ab50e71b7bfef36502480d03a6bb822c70e68cebdc560f26a5a8ffbad0ccc69
|
|
| MD5 |
c1a253cead30b6b1036841db15df0d37
|
|
| BLAKE2b-256 |
f3283cfd3a6d2a4361a25d2c2ae1ebc882005280d5b0bf405dae265911d3b8ec
|
File details
Details for the file toktak_config_fetcher-1.0.1-py3-none-any.whl.
File metadata
- Download URL: toktak_config_fetcher-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecd6dd5971d964242d3ca471dfa9e1e7d9efeca28a26952e03c49206ab785c21
|
|
| MD5 |
87557aa7b3f78665f1300f4f21089181
|
|
| BLAKE2b-256 |
b9bd105dfb7590d96ca0af42c06870648d291ed8e8f859688cad74d20f8d8186
|