1.0.0 • Published 5 years ago

@radarinc/node-vault-env v1.0.0

Weekly downloads
1
License
-
Repository
github
Last release
5 years ago

node-vault-env

A helper library for pulling Vault secrets and setting them as environment variables.

Usage

Install the package with yarn or npm.

yarn add

Call the vaultenv helper method:

import { vaultenv } from 'node-vault-env'

await vaultenv({token: 'yourvaulttokenhere'}, {ENV1: "secret/path.key1", ENV2: "secret/path.key2"})

The helper function will translate the environment variable mapping object into process.env values. In the above example the environment variable ENV1 will be set to the value of key1 on the secret located at secret/path.

Examples

The examples directory includes example uses of the node-vault-env library.

In order to run the examples, set the VAULT_TOKEN environment variable:

# If you have rv installed you can get your token from your current context
$ export VAULT_TOKEN=$(rv get-context | grep token | cut -d ' ' -f 3)

Direct Access

The direct access example illustrates how to instantiate the Vault object and call the loadEnv method directly. This example can be run with yarn example:direct.

Dotenv Like

Similar to the dotenv-style packages, this example illustrates how the helper function can be called to set environment variables in one function call. Note: the async nature of the helper.. This example can be run with yarn example:dotenv.