GithubHelp home page GithubHelp logo

vault-env's Introduction

Vault-env

The script adds .env.vault to the project and .gitignore file. According the Vault project configuration, script downloads relevant env variables

Description

Script creates .env.vault file and add it to .gitignore file. In .env.vault fille are stored all env variables and secrets form Vault for project. Every env variable is possible to override in .env file

Prerequisites

Project has to have implemented the identity-based secrets and encryption management system management Vault.

For using in Goodrequest you have to be in Goodrequest VPN

Usage

It is a good idea to clear the npx cache before running the script by following command (MacOs):

rm -rf ~/.npm/_npx

Add Vault script to package.json

"vault": "npx --yes https://github.com/GoodRequest/vault-env"

Update scripts where you would like to run Vault script

"prestart": "npm run vault && ...",
"debug": "npm run vault && ..."

Add vaultConfig script

import dotenv from 'dotenv'
import fs from 'fs'
import path from 'path'

// eslint-disable-next-line
['.env.vault', '.env'].forEach((name) => fs.existsSync(path.resolve(__dirname, `../../${name}`)) && dotenv.config({ path: name, override: true }))

Add config

vault: {
	url: process.env.VAULT_URL,
	roleID: process.env.VAULT_ROLE_ID,
	secretID: process.env.VAULT_SECRET_ID,
	secretsPath: process.env.VAULT_SECRETS_PATH || 'backend/PROJECT_NAME/backend/dev'
}

Add config type

export interface IVaultConfig {
	url: string
	roleID: string
	secretID: string
	secretsPath: string
}

Update config/default.ts

import 'dotenv/config' // As a first line
...

Update src/index.ts config/database.ts envValidation.ts

import './utils/vaultConfig' // As a first line
...

vault-env's People

Contributors

martin-durny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.