Reads parameters from AWS parameter store (if possible) or ENV.
Project description
SSMEnv
master | develop | PyPI | Python | Licence |
---|---|---|---|---|
SSMEnv allows you to read parameters from AWS Parameter Store and operate on results as on dictionary.
Installation
pip install ssmenv
Read parameters
Reading parameters is as simply as initialising class object.
from ssmenv import SSMEnv
ssmenv = SSMEnv(("/service/my-service", "/resource/dynamodb"))
# Accessing parameters
debug = ssmenv["SERVICE_MY_SERVICE_DEBUG"]
# As it's dictionary we can also:
# 1. Get list of all loaded parameter's names
list(ssmenv.keys())
# 2. Get list of all loaded parameter's values
list(ssmenv.values())
# and so on.
Populate os.environ
You can hide use of SSMEnv
by using os.environ
dict.
import os
from ssmenv import SSMEnv
os.environ = {**os.environ, **SSMEnv("/service/my-service")}
Remove common prefixes
Accessing your parameters through whole namespaces can sometimes be not convenient especially if you have very long names.
Hence why you can use prefixes
parameter, to make your code cleaner.
from ssmenv import SSMEnv
ssmenv = SSMEnv(("/service/my-service",), prefixes=("/service/my-service",))
ssmenv["DEBUG"]
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
ssmenv-1.0.0.tar.gz
(15.4 kB
view hashes)
Built Distribution
ssmenv-1.0.0-py3-none-any.whl
(4.7 kB
view hashes)