Easily switch between .env files #828
Replies: 5 comments 2 replies
-
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.
-
Hello, any updates about this topic ? I think it is a nice improvement that will help people migrate to bruno ! |
Beta Was this translation helpful? Give feedback.
-
My team and I only recently started using bruno and only today found out about these handlebars-style env vars. But our first and immediate grievances were indeed
On a sidenote, using a .env file doesn't even work for us right now. We're following the docs and our experience with .env files, and bruno even resolves the secrets when we hover over the handlebar names in requests, but the actual request is fired without replacing the |
Beta Was this translation helpful? Give feedback.
-
I gave up on I don't check my environments into the repo (my Other colleagues of mine commit their environments to the repo, but they use the "is secret" checkbox, so that the actual value is not saved in the environment. It's a super convenient feature, but it does not work for me, because I need those values in the cli runner as well, and currently, the cli runner has no way to read the secrets from the UI-secrets-store. |
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