Easily switch between .env files #828
Replies: 2 comments 1 reply
-
Hey @saibotsivad ! One approach is utilising prefixes (e.g., DEV, QA, STG) to distinguish between different environments.
DEV_AWS_ACCESS_KEY = secret
QA_AWS_ACCESS_KEY = secret
STG_AWS_ACCESS_KEY = secret And then in your envs
In this approach, your app would use a single variable Note: While each environment may contain numerous variables, only a small subset of them actually require secrecy. |
Beta Was this translation helpful? Give feedback.
-
I feel the same pain and like the ideas exposed here by @saibotsivad, I just wanted to add one more, which would be to optionally read an .env file found in an environment folder. This could take precedence over an .env file created at the collection root. |
Beta Was this translation helpful? Give feedback.
-
The Praise
The approach to managing secrets in a
.env
is really great, it's been pretty cool to be able to keep an.env.example
file in the git repo.Also, from within Bruno, the ability to switch between environments is great. You just pick one from the dropdown selector!
(I also suggest adding
.env*
and then!.env.example
to the.gitignore
so all.env
files are ignored except the example one.)The Pain
When storing secrets in the
.env
file, switching between environments actually requires the following steps (for example switching from staging to production):.env
files.env
to.env.staging
.env.production
to.env
That's a lot of work, and annoying!
Proposal?
There could be a way from in Bruno to pick which
.env*
file to use? That adds another dropdown selector, which isn't a great UX but could be okay.Or perhaps a way to associate a Bruno environment with a specific
.env
file? For example in a fileenvironments/Production.bru
there could be:This doesn't feel like a great solution either, because a user might desire to point to a different file than
.env.production
and then you'd have to remember to never check in theenv { file }
part of theProduction.bru
file.Are there other ways to manage this?
Beta Was this translation helpful? Give feedback.
All reactions