aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

Enhancement Request for Conditional Backend Builds and Build Dependencies in Amplify Gen 2 #3945

Open chelorope opened 4 months ago

chelorope commented 4 months ago

Before opening, please confirm:

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.

github-actions[bot] commented 4 months ago

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!