aws-amplify / aws-amplify/amplify-hosting
Amplify Console Host Web App flow not respecting the backend env name provided
- 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 read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] 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](https://github.com/gorbinphilip/react-amplify-sample) 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](https://us-east-1.console.aws.amazon.com/amplify/home?region=us-east-1) => 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
```yaml
=== 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](https://github.com/aws-amplify/amplify-hosting/tree/main/scripts) 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 :fearful: 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.
Contributor guide
Research direction
Start with the Amplify Console Host Web App flow and the scripts/ helper referenced in the issue, then compare behavior with the generated amplify.yml build settings. Reproduce the flow using a backend environment name that differs from the branch name and inspect which name is created and linked. Done means the provided environment name is retained for the backend and frontend CI/CD link.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, react
- Domain
- backend, cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100