r/platformengineering • u/NoDevelopment206 • 13d ago
how do you handle secrets for preview environments per pr
we want a preview env for every pr but the secrets part feels messy. sharing the staging secrets is easy but it feels risky since anyone can open a pr. curious if people make fake values per preview or give each one a scoped short lived secret.
4
Upvotes
2
u/Torutofu_Raeva 13d ago
e the deploy job runs the workflow from main, otherwise a pr can just edit the yaml to print whatever secret it's handed
2
u/Tinasour 12d ago
I dont know how you are generating environments, but i started using terraforms write only attribute more and more, new database, a random ephemeral string from terraform, writeonly written to secret manager, ansible terraform action depending on write only version which reads from secret manager to create the user, ecs mounts secret manager
And yes my workplace is small enough to not care for vault. Maybe vaılt has a better fit for this
1
u/LittleEnvironment970 6d ago
both tbh. fakes or sandbox keys for third party apis and for your own db a short lived cred per preview with a ttl, so it's useless once the env is gone, an infisical lease or one hush security issues to the preview's pods. github already keeps secrets from fork prs so dont undo that with pull_request_target
0
u/Starks1293 13d ago
id treat previews as their own environment tier and never hand them staging secrets. a preview runs code nobody has reviewed yet, so assume it leaks whatever it gets
what tends to work
and wire the teardown to pr close so nothing lingers, revoke the db user and delete the namespace