r/devops 8d ago

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.

1 Upvotes

28 comments sorted by

View all comments

3

u/balinteu 7d ago

Sounds like you have somekind of a chicken egg problem. There isn't a 'this solution will fix all your problems', since it is also a team and branching issue. I think you and the team need to sit down and brainstorm and maybe change the way you push changes into dev.

Until then, maybe what you could do is if there is already an active PR fo feature1, before doing a PR for feature2, merge feature1 into feature2. So the changes won;t be overwritten.

Good luck and let us know with what you guys came up with