r/webdev • • 20h 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?

12 Upvotes

40 comments sorted by

26

u/lbunch1 18h ago

I'm not telling

1

u/I_go_thither 8h ago

Secrets, secrets are no fun. Secrets, secrets hurt someone.

28

u/Saver411 17h 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.

2

u/harrymurkin 10h ago

This should be the top answer. Even for solo devs.

13

u/whoiami31 20h ago • Bravo

AWS kms free tier

10

u/scarfwizard 18h 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 20h ago

ansible-vault

4

u/zambono_2 19h ago

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

0

u/GarageFullStack 7h ago

That works until you need local parity. If your dev env doesn't mirror prod exactly, you'll spend hours debugging why a query fails locally but not on Lambda. I use AWS Secrets Manager for the actual storage, then pull via environment variables at cold start. It keeps the code clean but I still have to manage IAM roles carefully so my dev laptop doesn't accidentally hit prod.

1

u/30thnight expert 6h ago

It’s really not that hard brother

https://github.com/99designs/aws-vault

1

u/miria01 19h 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 12h 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.

1

u/No_Tradition6625 11h ago

I write them all on a sticky note and point my life camera feed at it... Or I use bitwarden πŸ€·πŸ»β€β™‚οΈ

1

u/vtshopjh 11h ago

Keyvaults, be it azure or openshift

1

u/IllImagination9652 7h ago

For a small team, what actually reduced the mess wasn't a fancy vault at the start. It was one rule: secrets never live in the repo, each environment has its own store, and nobody copies .env around in chat. Locally that's a gitignored .env. The recurring pain is always the same: someone updates staging and forgets production, or one key is shared by three services so you can't rotate it. I'd rather have slightly more repetition (one secret name per service per env) than a clever shared file. If you're already on a cloud, use that provider's secret manager before introducing another tool.

1

u/AhmedAmer2nd 4h ago

What helped us most was getting rid of shared .env files completely. Each environment pulls its secrets from one manager at deploy time (Doppler, Infisical, AWS Secrets Manager or Vault all work). Devs only get read access to dev and staging, and production keys can only be read by CI and the runtime role. That alone stops the "someone overwrote prod" problem. Also give each service its own credentials, so rotating one key doesn't break five apps.

1

u/Ecstatic-Text-2282 4h ago

What worked for our small team: secrets live in one place per environment (we use the hosting provider's env settings plus a password manager vault for the source of truth), and the repo only has a .env.example with every key name and a one-line comment. Prod credentials are readable by two people, period. Devs get their own dev/staging keys, so nobody ever has a reason to touch prod values. The thing that bit us most wasn't storage, it was rotation. Nobody knew which services used which key, so write that down next to each secret.

1

u/Open-Adhesiveness-86 3h ago

If you'd rather not run a secret store, sops with age keys works well: encrypted yaml committed next to the code, one file per env, decrypted at deploy time. Gotcha is offboarding, you have to re-encrypt everything AND rotate the values, since that person already read them. And if you do go AWS, Secrets Manager is $0.40/secret/month while Parameter Store SecureString is free with the same path layout.

1

u/Ahmed_Hisham0 3h ago

the part that bites later isn't storing them, it's rotating them. you can have a perfect vault and still have a prod key living in someone's .env from the one time they hotfixed something at 2am.

what actually worked for us: every secret gets an owner and a rotation date, and anything that can't be rotated inside an hour gets flagged. sounds bureaucratic, but it's the only thing that stopped the drift.

tooling: doppler or infisical if you want hosted, sops + age if you want them encrypted in the repo, and 1password cli is underrated for small teams because it injects at runtime so nothing lands on disk.

1

u/smkaisser 17h 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 20h 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.

0

u/kelkes 19h ago

Vault or infiscal.

-1

u/MacIsAGenius 9h ago

rails provides a good credentials management. you can create master.key and credentials (encrypted), so you can put your credentials in your repo and save master.key somewhere else. this helps a lot, since you will not have to manage all values in your vault. we can also create separate credentials per environment.

I want similar solution on my go project, so I created https://github.com/bogie-go/credentials. it's similar to that but it's in golang. in the world of AI, I think you can convert the code into the language you use.

let me know if this helps.