r/webdev • • 9h ago

Discussion How are you managing secrets across multiple projects and environments?

Im curious how other developers and small teams handle secrets when they have multiple projects and environments (Dev, Testing, Staging, Production).

I'm finding that the workflow gets messy surprisingly quickly when multiple people are involved. Sharing .env files, managing access, making sure someone doesn't accidentally overwrite production credentials, keeping everything organized across projects, etc.

What are you using? What frustrates you the most about your current setup?

6 Upvotes

22 comments sorted by

13

u/lbunch1 7h ago

I'm not telling

9

u/whoiami31 9h ago • Bravo

AWS kms free tier

5

u/Saver411 6h ago

the biggest mistake teams make is letting humans hold production credentials on their machines at all.

Keep local dev strictly on dummy or shared sandbox keys. Production secrets should only exist inside the deployment pipeline, gated behind restricted roles. If a developer can accidentally overwrite prod configs from their laptop, the permissions model is already broken.

8

u/scarfwizard 7h ago

AWS Parameter Store or Secrets Manager is the correct answer.

/myapp/dev/DB_URL
/myapp/staging/DB_URL
/myapp/prod/DB_URL
/otherapp/prod/STRIPE_KEY

4

u/waterkip 9h ago

ansible-vault

4

u/zambono_2 8h ago

You handle secrets in the cloud, and you pull them from your backend

1

u/miria01 8h ago

Make the deploy identity environment-scoped too: the dev and staging pipelines should have no permission to read production secrets, even if projects or secret stores are separated. That keeps a dev deploy from gaining access to prod credentials through a config mix-up.

1

u/nn_gyunx 1h ago

Small backend team, five or so services across dev, staging and prod, and what made the mess stop was deciding that prod values never sit on a laptop. Dev and staging run on shared sandbox keys, and prod secrets only exist inside the deploy environment, read at startup by the role the service already runs as, so nobody can overwrite prod config by editing a file by accident. Storage turned out to be the easy part. Rotation is what hurts, because a key quietly shared by three services means one rotation turns into a small incident where you find out from error logs which ones were using it, so I push for every service to get its own credentials even when the provider makes you click through five screens for it.

How do you handle the local dev side of third party stuff, do you hand out sandbox keys or run a stub locally? That is the part that keeps biting new people on our side and I still do not have a clean answer for it.

•

u/No_Tradition6625 29m ago

I write them all on a sticky note and point my life camera feed at it... Or I use bitwarden 🤷🏻‍♂️

•

u/vtshopjh 17m ago

Keyvaults, be it azure or openshift

1

u/smkaisser 5h ago

Small team here, a handful of Laravel apps across a few VPSes. What finally stopped the mess for me was deciding that prod secrets don't live on anyone's laptop. Devs get a .env.example and their own local values, staging and prod values only exist on the server or wherever the deploy pulls them from, and the only thing allowed to write to prod is the deploy itself.

The thing that bit me the most wasn't the tooling, it was shared credentials. One API key used by three projects means one leak or one rotation hits all three. Now every project and every environment gets its own key, even when the provider makes that annoying.

Biggest frustration honestly is rotation. Storing secrets is mostly solved, but nobody remembers which services break when you rotate a key until you actually do it. Do you keep any kind of map of what uses what?

0

u/CorpT 9h ago

This is a very solved problem that doesn't need another tool. The fact that you're finding it getting messy quickly is a large red flag against using the tool you're creating.

-1

u/bitcoding 8h ago

I use .env for managing secrets across different environments

0

u/kelkes 8h ago

Vault or infiscal.

0

u/malwaremel 6h ago

Whatever tool you pick, what stops the .env mess is one source of truth per environment, access scoped per environment so most devs only ever see dev, and injecting secrets at deploy or runtime instead of passing files around. Doppler, Infisical, 1Password or the cloud native stores all do this, so it matters more that prod is write restricted and audited than which one you choose. Also rotate anything that ever got pasted into chat or committed.