aws-amplify / aws-amplify/amplify-hosting
Enhancement Request for Conditional Backend Builds and Build Dependencies in Amplify Gen 2
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have removed any sensitive information from my code snippets and submission.
### Amplify Hosting feature
Backend builds
### Is your feature request related to a problem? Please describe:
Yes, my feature request is related to a problem I'm currently experiencing with Amplify Gen 2. I have configured my project as a monorepo, where an independent app is used to deploy backend resources, and two other apps are used to deploy different frontends. As decrived in the following article: https://docs.amplify.aws/react/deploy-and-host/fullstack-branching/monorepos/
The issue arises when I push any changes to the repository. Even if these changes are unrelated to the backend code, the backend app always triggers a build.
In Amplify Gen 1, there was an environment variable called AMPLIFY_DIFF_BACKEND that allowed the system to check for changes in the backend code and only trigger the backend build if changes were detected. This feature is not available in Amplify Gen 2, leading to unnecessary backend builds for every push to the repository, regardless of whether the changes are relevant to the backend.
This problem causes another issue when sharing backend resources with the frontend apps. To share these resources, I need to run npx ampx generate outputs --branch dev app-id AWS_APP_ID. This command works well unless the backend app is building simultaneously, in which case I receive the error: "Error: This branch deployment is in progress. Re-run this command once the deployment completes." Since the backend app deployment currently runs for every change pushed to the frontend code, this error occurs frequently, disrupting the development workflow.
### Describe how you'd like this feature to work
I would like Amplify Gen 2 to introduce a feature similar to the AMPLIFY_DIFF_BACKEND environment variable that was available in Amplify Gen 1. This feature should check for changes in the backend code and trigger the backend build only if changes are detected. This would prevent unnecessary builds and improve the efficiency of the build process.
Additionally, I would like a feature that allows one app to wait for another app to finish building before it starts its build process. This feature would work similarly to dependencies used in GitHub Actions, ensuring that dependent builds do not interfere with each other. For example, if the backend app is building, the frontend apps should wait for the backend build to complete before starting their build processes. This would prevent the error "Error: This branch deployment is in progress. Re-run this command once the deployment completes" and streamline the development workflow.
Contributor guide
Research direction
Start with the linked Amplify Gen 2 monorepo documentation and the reported AMPLIFY_DIFF_BACKEND behavior from Gen 1, then trace the backend build flow and the `npx ampx generate outputs --branch dev app-id AWS_APP_ID` entry point. Done should include a supported way to skip unaffected backend builds and coordinate dependent frontend builds without the branch-deployment-in-progress error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws
- Domain
- ci-cd, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100