r/devops • u/Downtown_Custard20 • Jul 23 '26
Architecture Terraform/Github deployment overwriting another deployment
I'm on a team that shares a Github repository. Whenever we open a PR from a feature branch to the dev branch, a deployment to the AWS development account is automatically triggered.
The issue we're facing is that one developer may deploy to dev, and then another developer deploys afterward. Even though they're working on different files, the second deployment ends up overwriting the first developer's change in AWS.
How can we prevent this?
We're following a Gitflow workforce (feature -> dev -> release -> main), and our biggest challenge right now is that the second developer's code is often "outdated" when it's deployed, causing it to overwrite changes that were already deployed by someone else.
We tried merging everything to dev, but when it's time to deploy to prd, the dev branch ends up filled with a lot of unnecessary changes.
We using Github Actions + Terraform.
View all comments
Show parent comment
2
u/aprettyparrot Jul 24 '26
I don’t think dev should be shared. Everyone should test their feature branch against their own dev env.
It sounds like you’re missing a staging env.
You can’t really split the code as feature1 and feature2 once they are merged together. I would say the simple solution is just management review and staging. You only want feature1 in this release, then you leave that feature2 unmerged. Staging would let you then test that feature2 can coexist with feature1.
I think I got that right, been a long day
EDIT: snowmobile said it way simpler than me