Skip to main content

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

  1. 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
  1. Install doppler-env in your local development environment:
pip install doppler-env
  1. 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
  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

doppler_env-0.1.1.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

doppler_env-0.1.1-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page