Automatically inject Doppler secrets as environment variables for use during local development
Project description
doppler-env
Inject Doppler secrets as environment variables into your Python application during local development. Provides debugging support in PyCharm, Visual Studio Code, and other IDEs and editors.
Inspired by patch-env.
NOTE: This package should be used during local development only. It is not suitable, recommended, or supported for production usage.
How it works
Debugging in IDE's such as PyCharm and Visual Studio Code do not allow the Doppler CLI to be used as the process runner for Python as they use their own Python debugger entrypoint. This often forces developers to resort to insecure practices such saving Doppler secrets to an .env
file during development, the very problem Doppler was created to prevent.
The doppler-env package provides a solution in the form of a site hook that is run at Python startup.
If the DOPPLER_ENV
environment variable is set, the package will call out to the Doppler CLI to fetch secrets for the project and inject them as environment variables into the process spwawned by the commmand line or IDE with your secrets never touching the file system.
Requirements
Ensure the Doppler CLI is installed and you have created a project in Doppler.
Then authenticate the Doppler CLI so it can retrieve secrets from your workplace:
doppler login
Getting started
- If you haven't already, open a new terminal window, change into the repository folder, then configure the Doppler CLI by selecting the project and config for development:
doppler setup
- Install
doppler-env
in your local development environment:
pip install doppler-env
- On the command line or in your editor, set the environment variable
DOPPLER_ENV
to trigger injecting secrets as environment variables:
export DOPPLER_ENV=1
- Run or debug your application as per normal:
python src/app.py
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 doppler_env-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1e1dad4ebf50a85d1170e6dd403907cfd91ba71f173ef8b025648886c58c734 |
|
MD5 | 96411662c541061a739b704ab9c4a095 |
|
BLAKE2b-256 | 9a986c15eb5efba42fb28b0c8f92e7f415db353e168ac8bf66f3b66cd3c4c6ce |