No project description provided
Project description
psenv -- (Parameter Store Environment)
a cli tool for managing environments stored in the AWS parameter store
When working on teams with multiple developers, who may each have their own local development environment,
it can be challenging to make sure that each environment has the same set of base parameter values in a .env
file to get the base project up and running. It can be common that as a project grows over time, there can be 100s
of environment variables which contain everything from project configuration values, to database connection strings,
or even secret API keys and tokens.
Sometimes developers may need to keep multiple .env
files locally for different projects, each of which may have a
different set of parameters. This can become quite difficult to manage across multiple medium to large size teams.
This is where psenv
comes in, to help those of us who are working within the AWS cloud ecosystem.
Getting Started
pip install psenv
However, since psenv
works well as a globally available command, the preferred method of installation is to use pipx
pipx install psenv --include-deps
For those of you who are unfamiliar with pipx
, it can be thought of as a "Homebrew for python applications".
Check out the amazing project here ---->>> https://pypa.github.io/pipx/docs/
Initialization
After installation, psenv
needs to be initialized and configured. To speed this up you can run
psenv init
This will create a directory at ~/.psenv
and a config file at ~/.psenv/psenv.yml
as well as an environment file
~/.psenv/psenv.env
Setting Up An Environment
Open the ~/.psenv/psenv.yml
file in your editor of choice and make an entry.
environments:
my_project_name:
path: /the/path/used/in-the/aws/parameter-store
env: /path/to/local/env/file/.env
The environments
key is a list, which can take as many environment definitions as you like.
Commands
At any time you can type psenv --help
for a list of commands.
psenv --help
psenv <command> --help
Displaying Configured Environments
To display the environments configured
psenv show
You should see a list of all available environments formatted in your terminal as a table. This can come in handy as we will later need to reference the configured environments for the other commands
Fetch an Environment from the AWS Parameter Store
This command will fetch all the parameters on the path configured in the path
section of the psenv.yml
file
psenv fetch --env my_project_name
Push and Environment to the AWS Parameter Store
Sometimes you need to set up new environments. This is easy with psenv
add an entry in psenv.yml
environments:
new_env:
path: /some/parameter-store/path
env: /path/to/.env
populate the .env file with the secrets and parameters you need for your environment and then run
psenv push --env new_env
Private Environment Variables
Sometimes a project my have some environment variable where the value is known up-front. (eg. Project Configs), however there
may be some values which need to remain secret. After all, it would not make much sense for a developer to store there personal
github token in the parameter store for others to copy and use. For this case we have the #<private>
section in the .env
file.
All variables declared under the #<private>
section in the .env
file will be ignored automatically by psenv
Credential Injection
Sometimes you might want to copy some environment variables from your current terminal session environment to a .env file. Example when you use temp AWS credentials and need to load them into more than one project / environment. To do this, get your creds however you normally would and then
psenv inject --prefix aws --env some_env
all your aws credentials will be injected to your .env file! Like Magic!
Variable Templating
When configuring an environment to be shared, it is sometimes helpful to give developers hints as to what type of private credentials will be needed to get the code to behave as expected. This is where templating comes in.
psenv
allows you to define a placeholder in your .env
file using the prefix PSENV__TEMPLATE__
that will be templated upon running the fetch
command.
For example, we have a project that requires a github token, and we want to make this obvious for the next developer we onboard. In our source .env
file,
we simply declare a variable called PSENV__TEMPLATE__GITHUB_TOKEN
. We then run psenv push --env <your-env>
to push these values to the parameter store.
SOME_VARIABLE1=123
SOME_VARIABLE2=234
PSENV__TEMPLATE__GITHUB_TOKEN=<REPLACE-WITH-YOUR-PERSONAL-GH-TOKEN>
The next developer we on-board simply needs to run psenv fetch --env <your-env>
and the below will be created.
SOME_VARIABLE1=123
SOME_VARIABLE2=234
#<private>
GITHUB_TOKEN=<REPLACE-WITH-YOUR-PERSONAL-GH-TOKEN>
If you would like to fetch the environment values without using the template function, you can pass the --no-template
flag to the fetch
command, which will then fetch the raw parameters as they were created. This is useful if an admin needs to add, or remove some parameter
from an environment.
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
File details
Details for the file psenv-0.17.1.tar.gz
.
File metadata
- Download URL: psenv-0.17.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e863c1a8d131d48db2dab560a75c032ab39b66ed01743d5ef73cdee9c623b67 |
|
MD5 | 7278bd1e82da7ae95bc3375feb6dc5d1 |
|
BLAKE2b-256 | 86e93b536e94e93cd5d4c83553537b114168425f67d9f9fafadb9461365c97d6 |
File details
Details for the file psenv-0.17.1-py3-none-any.whl
.
File metadata
- Download URL: psenv-0.17.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 466fcae836ab162a90449b4f9c978594588753f9ad00b76949e51007ff68cf41 |
|
MD5 | 25b5c0fe306c64eba2aa5d2dc7fb2826 |
|
BLAKE2b-256 | ca9e4350fefa4abf56b0e325d423d8e842da8728ef1cc78af72be96ee89e9c5a |