Visual Studio Code

reading time 5 mins

The Doppler CLI enables you to say goodbye to using insecure .env files locally and the guides in this section will help you quickly and easily integrate Doppler into your local development and debugging workflow for Visual Studio Code.

How it works

If you're new to Doppler, you might be using the envFile in your launch configurations or your application might be populating its environment variables using a .env file in combination with a dotenv package.

The good news is that with the Doppler, you'll never need an .env file again!

Doppler fetches your secrets and injects them as environment variables every time you run or debug your application, preventing unencrypted secrets in .env files from ever touching the file system.

πŸ“˜

Once you've imported your secrets into Doppler, delete any references to .env files in order to confirm all secrets are originating from Doppler.

Prerequisites

Node.js

Adding a new Doppler launch configuration for Node.js applications is easy and if updating an existing launch configuration, simply change the runtimeExecutable field to be doppler and prepend the existing runtimeArgs with two Doppler CLI specific entries.

A typical Node.js Doppler launch configuration looks like this.

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "node: server",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "doppler",
      "runtimeArgs": [
        "run",
        "--",
        "npm",
        "start"
      ]
    }
  ]
}

Python

Python launch configurations rely on a Microsoft-developed Python debug library which prevents us from configuring the Doppler CLI as the runtime executable.

To work around this limitation, we created the Python doppler-env package that when enabled by setting the environment variable DOPPLER_ENV, will inject Doppler secrets as environment variables into the Python debug process before your application code is run.

To use, install the doppler-env package or add it to your development-specific requirements file:

pip install doppler-env

A typical Python launch configuration should look similar to this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "python: server",
      "type": "python",
      "python": "${env:HOME}/.virtualenvs/your-app/bin/python",
      "request": "launch",
      "program": "your-app.py",
      "env": {
        "DOPPLER_ENV": "1" // Enable doppler-env to inject secrets on start
      }
    }   
  ]
}

πŸ‘

Awesome Work!

Now you know how to use Doppler for secure secrets management when debugging Node.js and Python applications locally using Visual Studio Code.


Did this page help you?