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

Is it possible to use 2 different platforms in one amplify app? #3907

Closed yafimvo closed 5 months ago

yafimvo commented 10 months ago

Before opening, please confirm:

Amplify Hosting feature

Monorepo, SSR

Is your feature request related to a problem? Please describe:

I have a monorepo with two applications: one in React and another in Next.js. Each project has its own amplify.yml in its root folder. While I was able to build both applications in my Amplify, the CI/CD doesn't work properly because the app's platform should be 'Web' for React and 'Web compute' for Next.js. As a result, I need to manually change it every time I want to deploy one of them.

Also, a follow up question - is it possible to set the AMPLIFY_MONOREPO_APP_ROOT from one of the configuration files?

Describe how you'd like this feature to work

Generally, my goal is to connect both monorepo folders (react and nextjs) into 1 URL, i.e. https://example.com which is hosted on Amplify. Then, for every example.com/app2, this should show the Next.js app; otherwise, it should show the React app. I was able to achieve this with a rewrite, however, I wonder if there is a simpler way to do it that will also support CI/CD.

github-actions[bot] commented 10 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!

kvramyasri7 commented 9 months ago

Any update? trying to do the same and few folks are reaching out to ME!

kvramyasri7 commented 9 months ago

cc: @Milan-Shah @chrisbonifacio

kvramyasri7 commented 9 months ago

Ummmm, oops have not realized have opened a duplicate copy/paste issue sorry u guys !!!!

yafimvo commented 9 months ago

Ummmm, oops have not realized have opened a duplicate copy/paste issue sorry u guys !!!!

@kvramyasri7

Thanks for bumping it up! I'm still waiting for a better solution since the CI/CD is quite a mess.

Maybe a quick solution would be allowing to update specific env params.

this way I can write a small github action script that runs whenever I want to deploy NextJS to Amplify (I can do it now but I need to share all of my Amplify secrets).

Something like this:

  1. Change the platform
aws amplify update-app --app-id <my-app-id> \
    --platform WEB_COMPUTE 
    --region <my-region>
    --update-environment-variables AMPLIFY_MONOREPO_APP_ROOT=nextjs
  1. push to my main nextjs branch branch, i.e., main_nextjs_branch, to invoke the build on Amplify

  2. After a successful build - return the platform to WEB

    aws amplify update-app --app-id <my-app-id> \
    --platform WEB 
    --region <my-region>
    --update-environment-variables AMPLIFY_MONOREPO_APP_ROOT=react

Note I tried to create a conditional variable but it doesn't work for AMPLIFY_MONOREPO_APP_ROOT so fixing this might be also useful.

mauerbac commented 5 months ago

Going to close this issue as it seems to be resolved. Please re-open if you still need help or check out our Amplify Discord!

github-actions[bot] commented 5 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] commented 5 months ago

This issue has been automatically locked.