question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Repeated merge conflicts due to multi-env workflow

See original GitHub issue

Hello,

I am using amplify with multiple environments and a CI pipeline, and I am facing a specific problem. I am not sure whether this is due to a lack of understanding of the deployment process?

I have two environments, dev (development branch) and prod (master branch).

My workflow is as follows:

  • on dev/development work on frontend/backend, push resources using amplify publish
  • commit changes
  • git checkout master && amplify env checkout prod
  • git merge development
  • amplify status shows me that I changed stuff and the backend will be updated
  • amplify publish

This is all fine, the problem starts now:

When published on prod, there are file changes. The diff shows that the changes are only related to a key “Code” in the lambda functions’ cloudformation templates in the backend folder:

/amplify/backend/function/function_name/function_name-cloudformation-template.json

"Code": {
-   "S3Bucket": "app_name-20190716141290-deployment",
+  "S3Bucket": "app_name-20190716180513-deployment",
     "S3Key": "amplify-builds/function_name-ru14rdtn1erne110ne-build.zip"
}

In the docs, it is said that these files should be committed. However, when committing such changes, I repeatedly get a merge conflict when merging new changes from development because then master has already diverged.

I thought about storing the backend folder in an S3 bucket for dev and prod each to avoid this versioning problem, but I am not sure whether that’s intended.

What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
plaacommented, Apr 25, 2020

@RossWilliams @kaustavghosh06 If those changes aren’t supposed to be committed, then Amplify should not make the changes. Amplify could make a temporary copy of the file and update that instead of editing the git version.

The whole issue is that Amplify is making changes into source files, which then manually need to be avoided. It’s a pain especially when editing the CF files (see my original comment).

Also not committing the files has the negative impact of having them be deployed every time even though nothing has changed.

1reaction
RossWilliamscommented, Dec 10, 2020

@chantlong This sounds correct, status is going to show function updates, and pushes are going to take a bit longer. I don’t commit the new keys in the way you describe mainly because our automated pipelines and policies don’t support it. If you have a production branch that you can commit to directly, your method does sound good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Repeated merge conflicts due to multi-env workflow #7397
I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists. I have searched for...
Read more >
Are Frequent Complicated Merge Conflicts A Sign of Problems?
Merging into main branch must never have any conflicts. You always merge main to feature first, so feature to main is then conflict...
Read more >
git workflow: merging and fixing conflicts once - Stack Overflow
If multiple developers are working on their respective dev/XXX branches; when they merge into staging , sometimes, they create conflicts.
Read more >
How to Resolve Merge Conflicts in Git? | Simplilearn [Updated]
1. Starting the Merge Process ... If there are changes in the working directory's stage area for the current project, merging won't start....
Read more >
How to Prevent Merge Conflicts (or at least have less of them)
Sometimes, you will have to repeatedly resolve the same conflict while rebasing. ... There's no correct workflow – just preferred ones.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found