Builds a config object based on environment variables, settings files and (optional) parameters stored in AWS System Manager Parameter Store.
Project description
Manage Conf
Description
Builds a config object based on environment variables, settings files and (optional) parameters stored in AWS System Manager Parameter Store.
The config object merges in config, overriding any previous key/value pairs, in the following order:
- ENV
- default config: default.yml
- stage config: {stage}.yml
- remote config: remote_settings (AWS param store)
Available to download as a package on PyPi.
Settings Files
Set an environment variable with the key name project_config_dir
. It is important this is set before the package is imported. The value of project_config_dir
should be the location of your /settings
folder.
Set-up your settings folder, adding in configuration to the appropriate file.
-- /settings
---- default.yml
---- {stage}.yml
---- {stage}.yml
Example configuration:
# default.yml
project_name: example-project
# local.yml
use_remote_settings: false
# dev.yml
use_remote_settings: true
AWS
Add parameters in your AWS account with paths that match this pattern:
/{project_name}/{stage}/
If you set use_remote_settings: true
in a stage.yml config file, the package will attempt to fetch the parameters from the store that have this base path.
Using the example configuration above, the path would be:
/example-project/dev/
Usage
Make sure you set project_config_dir
before importing.
from manageconf import Config, get_config
SECRET_KEY = get_config("SECRET_KEY")
DEBUG = get_config("DEBUG", True)
Development
Install
Requires Poetry.
# create a Python3 virtual environment
virtualenv -p python3 env
# activate the virtual env
source env/bin/activate
# install requirements
poetry install
Tests
# run tests
pytest -vv
# coverage report in the Terminal
pytest --cov=manageconf tests/
# coverage report in HTML
pytest --cov-report html --cov=manageconf tests/
Project details
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
Hashes for manageconf-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ae7a22ee0ecf5d8f9bdcab489368f0377655db8b285c7812fe93e242ba0929 |
|
MD5 | 1638f7999f459fa900b73c4053c06d17 |
|
BLAKE2b-256 | 96c1e4fbaf13491be7e61ffe8ab2bf908f3b62f1108d6d84b039f9027f44dc1b |