dotenv-vault icon indicating copy to clipboard operation
dotenv-vault copied to clipboard

Pass dotenvVault as argument

Open www-chique opened this issue 2 years ago • 2 comments

Proposal

Ability to pass DOTENV_VAULT in arguments in the command line. For example: npx dotenv-vault pull production --dotenvMe=me_b1831e… --dotenvVault=vlt_0a2981c4d...

Why?

I have the same code deployed across multiple production "apps", which vary from one another purely based on some environment variables, such as "SITE_TITLE", "API_LINK", and so on. When I deploy it to production using a service, it pulls the environment variables using dotenv-vault pull, builds the app, and deploys. Since I want to use the same repository for different apps, I would like to pull different set of env variables depending on which app it is. This can be achieved if I can supply the dotenvVault argument in the build command, and hence, won't need to commit the .env.vault (or .env.project) into the repository and lock the repository to one particular app.

Alternatives I have thought

  1. Using different "environments" for each project, like dotenv-vault pull production_projectA and dotenv-vault pull production_projectB and so on, but the experience will not be good when it comes to managing the projects.
  2. Creating different repositories and including the main repository as a dependency, so each repository can have it's own project, while the shared code goes into the dependency. This isn't feasible for me (the entire project is shared, so it doesn't make much sense to create an empty repository with just one dependency, and a .env.vault file).

I'll be very happy if someone can point me to the right direction, not necessarily the solution I have proposed.

www-chique avatar Jan 25 '23 16:01 www-chique

Interesting and good use case. Putting this on the roadmap.

motdotla avatar Jan 25 '23 18:01 motdotla

For now you can do DOTENV_VAULT=vlt_1234 npx dotenv-vault pull production --dotenvMe=me_b1831e…

motdotla avatar Nov 04 '23 06:11 motdotla