Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify Console Host Web App flow not respecting the backend env name provided #3745

Open
5 tasks done
gorbinphilip opened this issue Oct 6, 2023 · 7 comments
Open
5 tasks done
Labels
backend-environment bug Something isn't working console The issue is related to performing an action in the Amplify console

Comments

@gorbinphilip
Copy link

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

NEW_APP

AWS Region

us-east-1

Amplify Hosting feature

Backend environments, Console, Deployments

Frontend framework

React

Next.js version

N/A

Next.js router

N/A

Describe the bug

Amplify console let's you provide the name for the new backend environment while hosting the web app. It used to create the backend env with provided name and link with the frontend for CI/CD fullstack deployment.
However, currently it is either using the name of branch when possible or randomly generates a name.

Expected behavior

Backend environment should be created with the name provided and that should get linked to the frontend

Reproduction steps

  1. Fork this repo or setup any fullstack repo without amplify.yml file (so that default behaviour gets kicked in) in github (less likely to be provider dependent).
  2. Open Amplify console => New App => Host Web App.
  3. Select the repo, branch etc.
  4. Select create backend environment option and provide the name which is different from branch name & complete steps.
  5. Wait for deployment to finish.
  6. Check the backend env name

Build Settings

=== Note: this is the auto generated version itself

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Log output

# Put your logs below this line
N/A

Additional information

Repo URL: https://github.com/gorbinphilip/react-amplify-sample
Recording: https://github.com/aws-amplify/amplify-hosting/assets/41995531/39b8e7f9-98fe-4169-af93-5d9519467396
Screenshot: https://github.com/aws-amplify/amplify-hosting/assets/41995531/bfe8b30f-7300-4020-a69e-2da2a4f49864

Feel free to skip if clock is ticking too fast.

At least this was working while amplifyPush helper script was around. Which I still continue using by manually adding to the existing deployments running cli v5.6 out of fear (keeping some magical commands in that script is scary as well, but boy do I have a choice).

Well, the reason for that is because amplify team decided to remove that out of the blue and backend builds were no longer happening. So we had to hack (apologies for the bragging but that was really unprofessional). From docs, I see that now amplify hosting scans for the presence of amplifyPush command and automatically manages backend deployment for backward compatibility.

Now at present, while I'm scratching head exploring the options to migrate to latest cli and get rid of hacks, there comes this env name trouble. Now I am wondering what would be the effect of getting rid of the helper script from existing deployments and just put the magical word amplifyPush --simple. Well, who knows if amplify would randomly setup a new backend env 😨 and connect that with the frontend.

Some might ask, why not just try and see for yourself. Well, for my luck nodejs12.x is no longer supported by AWS lambda which is magically used by cli 5.6 for different categories and that prevents me from spawning new envs to play with. I'll give a shot with the new repo and update later on this one.

@gorbinphilip
Copy link
Author

Update:

Looks like the issue is caused from console not injecting the env variable required: USER_BRANCH
Works as expected if this is manually added. This used to get added automatically for the branch earlier based on the provided value.

@Jay2113 Jay2113 self-assigned this Oct 10, 2023
@Jay2113
Copy link
Contributor

Jay2113 commented Oct 10, 2023

Hi @gorbinphilip 👋 , thanks for raising this issue and for sharing detailed reproduction steps.

I was able to reproduce this behavior and I am going to mark this as a bug. Additionally, you've correctly mentioned that the issue seems to be related to the console not setting the USER_BRANCH environment variable with the backend environment name that is passed during the app creation workflow.

The workaround for now is to manually set the USER_BRANCH environment variable to the backend environment name that is being used during the app creation workflow. Kindly refer to the attached screenshot:

Screenshot 2023-10-09 at 5 56 04 PM

@Jay2113 Jay2113 added bug Something isn't working backend-environment console The issue is related to performing an action in the Amplify console and removed pending-triage labels Oct 10, 2023
@bergmorten
Copy link

Any update of this. Has the website been updated or must we still enter user branch as environment variable?

@gorbinphilip
Copy link
Author

gorbinphilip commented May 15, 2024

Fast forwarding to 2024, AWS amplify console has reached to a stage where it doesn't respect any of the build package overrides. Whatever you configure cli version, node version etc.. it just installs whatever it feels like. Currently when requesting, node 18, amplify cli 12.11 with Amazon Linux 2023, console goes ahead and configures node 14, amplify 12.12.
https://discord.com/channels/705853757799399426/1239554630153670697/1239554630153670697

Have never used a service from AWS that's this unreliable. I do appreciate that most of the components are open source and iterated in fast pace, but that doesn't justify breaking core parts. Not to mention the fact the idea was to set a project up and running without head scratching too much about infra.

Apologies once again for the rant here because AWS doesn't have a provision to report or reach out without a paid developer plan. This probably has nothing do with open source side of amplify but just AWS

@bergmorten
Copy link

Yes, and I think the new design of the new amplify console is much less intuit. And still there is no button for manual build, you must enable CI and push a commit to build.

The new UI also duplicate global build settings as branch environments variables. So if after the first deployment and want change a global build environment variable, you must also change the variable for all build branch.

@mauerbac
Copy link
Member

Are you still experiencing this issue?

@mauerbac mauerbac added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jun 27, 2024
@bergmorten
Copy link

bergmorten commented Jun 27, 2024 via email

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-environment bug Something isn't working console The issue is related to performing an action in the Amplify console
Projects
None yet
Development

No branches or pull requests

4 participants