r/devops • u/Sweet_Good_2358 • 2d ago
Discussion How are you managing secrets across multiple projects and environments?
I'm 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?
37
Upvotes
47
u/Efficient-Branch539 DevOps Engineer 2d ago
We manage secrets with Hashicorp Vault and inject in applications at the runtime. There are many ways you can do this depending on the infrastructure.
25
u/centech 2d ago
Mostly AWS Secrets Manager w/ ESO to expose them in EKS. Still SM when it's not EKS.. which for us mostly means Lambdas.
16
u/New-Entertainer6392 DevOps 2d ago
I'm in azure and use azure key vault, assume the aws one is the same...
Vault per env, same named keys on each, just different values.
Some apps get the keys themselves from keyvault, some get them via env vars (and that's specially injected by k8s
30
u/nextlandia 2d ago •
Openbao
7
u/KevMar 2d ago
You keep the secrets in each environment. Either key vault or secrets manager. Then you only give devs direct access to the lower environments and the only thing that touches prod is the pipeline.
5
u/sp_dev_guy 2d ago
Different readdit posts - newest comment is the current password. Systems do a lookup on init.
Free storage, HA, no vault or master password to protect. Rotation & uptime are easy with no maintenance required
4
u/Aide_Sea 2d ago
Whatever tool you pick, I think the bigger fix is just that people don't have prod access at all. Devs read dev and staging, only the deploy pipeline can read prod. Then nobody can overwrite prod creds by accident, and offboarding is way less scary :)
4
u/raisputin 2d ago
I just set them all to “password” and call it good, nobody ever guesses that 🤣🤣🤣🤣🤣
J/k
6
u/scottgal2 2d ago
I use Infisical. Pretty easy to manage access & allow editing, auditing etc.
3
u/Fit-Main6094 1d ago
Infisical
2
u/kloudnative 2d ago
AWS secrets manager
2
u/JusticeWarner 2d ago
Vault
2
u/Azy-Taku 1d ago
We have a self hosted instance of infisical, which gives project based access across environments.
3
u/___-____--_____-____ 2d ago
As a solo dev I make heavy use of sops. Nixos (which my compute hosts run) and FluxCD (which is how I configure workloads) both integrate with it pretty seamlessly. I've been happy with it so far. Having secrets be versioned kind of eliminates the overwrite scenario, and since everything just applies what is in git, rotating secrets etc is kinda nice. Or at least, a lot less hands-on than I was used to.
https://github.com/streetfortress/forts
2
u/akhilesh_gone 2d ago
U can use sops with sops u can push the envs to git as sops encrypt them
1
u/PrestigiousStrike779 2d ago
AWS secrets manager and IAC (CDK) to configure on deploy. For most things we allow either a direct load of the value from environment variable or a secret. The direct value works well for a local Postgres connection for example while a deployed environment loads from a secret. Developers/QA only have access to the secrets in the develop account if it’s needed for local installs. Everything is configured by environment variables (including what secret to load), no .env files are checked in.
1
u/snopedom 2d ago
We have SM per env, each env is its own AWS account. External Secrets binds them into k8s by app/namespace prefix, so every app only sees its own secrets. Nobody touches prod secrets by hand, so nothing gets overwritten by accident
1
u/NoPomegranate9625 2d ago
We have a strict ” everything on gcp secret manager” policy.
Each service we build fetch them directly so the k8s manifest only need to contain the name of the secret. (Combined with a simple secret name scheme it is super efficient)
For the few services we don’t build we resolve the secret into a three actual value at config generation time. They end up in the config but it is ok. (Minimal number of services have k8s api access in prod)
1
u/Official_BetterSWE 2d ago
the other half is having fewer static secrets to share at all. CI can use OIDC to get short lived cloud creds instead of a stored access key, and vault can hand out db creds that expire on their own. then the .env sharing problem shrinks to a handful of third party api keys, which is way easier to keep tidy
1
u/dusanodalovic 2d ago
sops with age here too, and what fixes the overwrite worry is one age key per environment. in.sops.yaml you add a creation_rule per path, so secrets/dev/ is encrypted for the team key and secrets/prod/ only for the key that lives in ci. devs still see the prod file in git, they just cant decrypt or edit it, so nobody overwrites prod with their local value by accident. one more reason to drop plaintext.env files: if you run coding agents in the repo, the agent and every tool it starts can read them. encrypted files in git dont have that problem
1
u/engineerL 1d ago
We avoid secrets like the plague. The one secret we can't get rid of, we put in GH Actions Secrets.
1
u/Downtown_Cat_7425 1d ago
For small projects, the thing that helped me was separating where a value lives from how the app reads it.
The mistake I kept making was copying a staging value into production because the name matched. Prefixing each name with the environment and checking them at startup caught that.
Vault-style tools make sense as a team grows, but these basics remove most of the "who overwrote the credential" mess.
1
u/NoDevelopment206 1d ago
for a small team i'd keep it simple. parameter store or sops in the repo covers most of it and costs almost nothing. vault is great but you end up running and unsealing it, which is a real job on its own. the thing that bites people is prod secrets being editable by everyone, so i'd split access per environment first and worry about the tool after.
1
u/DoOmXx_ 1d ago
infisical or doppler if vault is overkill, just keep prod creds off laptops
1
u/jaeckanaquth 18h ago
Github secrets, aws secrets manager, Azure keyvault
1
u/java_bad_asm_good 2d ago •
Coming from AWS Secretsmanager and ESO, my current company uses SOPS and it‘s really grown on me. All secret changes are auditable in git, and write-only changes (by granting kms:Encrypt but not Decrypt) are straightforward.
1
u/carsncode 2d ago
Dev access: non-prod only, via 1pass
op runusing placeholder env filesRunning services: separate vault per environment, synced in with ESO
0
u/khaled_shehata 2d ago
I've been reading about exactly this while studying DevOps. The pattern that comes up most in docs and talks: .env files stay local and out of git, pipeline variables (GitHub Actions / GitLab CI) hold the per-environment values, and for sharing across a team people usually point to SOPS or HashiCorp Vault. The mozilla/sops README on GitHub explains the SOPS approach well. Curious — for a team of 2-3 people, is Vault overkill compared to SOPS?
-1
u/nickjj_ 2d ago edited 2d ago
One thing I came up with for a medium sized team that worked nicely was:
(1) encrypted and versioned S3 bucket
myapp/.env.stagingoranotherservice/.env.productionA ~200 line general purpose shell script to handle downloading, uploading and diffing which was called such as
./secrets myapp --env development, it had all sorts of quality of life things like protection against overriding files by accident, etc.Developers loved it because keeping shared env files in sync was so easy, you can see what changed and it didn't involve copy / pasting values from anywhere.
It also worked nicely in CI and production because all access control was handled by IAM permissions. It was really easy to onboard and offboard folks since it was related to AWS access. It was also easy to limit access to production credentials.
It ticked every box we wanted and also had no problem passing various compliance checks. It was also extremely cost efficient (side bonus).