Open raffibag opened 2 years ago
Hi @raffibag 👋 thanks for raising this issue. Because it's related to the CLI commands, I'm going to transfer this issue over to the CLI repo for better support.
Hey @raffibag :wave: this is expected behavior. While the amplify/
folder is generated when we're choosing not to modify the backend it is a lightweight addition that contains information regarding the pulled app and environment, which enables us to later run amplify pull
to keep our project in sync without also specifying the appId
and envName
. However, I do see in our docs where it mentions this will only create the aws-exports.js
file where this does not appear to be the case.
Marking as a documentation issue 🙂 and I'm going to dig deeper into the amplify/hooks/
directory that is pulled
Thank you, @chrisbonifacio and @josefaidt for the additional details. I appreciate the clarification!
Sorry to bring this up again, but is it also expected behavior for the above command to create a backend environment? I guess that's what the original question was. While I had been using amplify pull
to get the aws-exports.js
file, it's recenly been creating a backend app, resulting in two issues:
1) When deploying to amplify by committing the code to the Amplify-linked git repo, it fails on backend build; and
2) When using amplify pull
a second time, I'm receiving the following error (though that App doesn't - and shouldn't - exist):
Failed to pull the backend.
App d18xd0t******* not found. Check that the region of the Amplify App is matching the configured region.
It seems like it's creating a backend service... Is there some sort of config I should be looking for to prevent this from happening - or, again, is this expected behavior? Note, I did confirm the region as configured is correct (us-west-2).
Hey @raffibag it sounds like we may have an App ID mismatch or a case where the backend is actually created. There is currently a limitation on using a backend without choosing to modify where we are unable to add additional services like hosting. Can you confirm whether you're seeing two different App ID's between the first app (with the backend definition) and the second app (using the same backend)?
Thank you @josefaidt... I can confirm that the app containing the backend and the front-end only app have the same AmplifyAppId
(d18xd0t***) inside the team-provider-info.json
file. I can also confirm the apps are in the same us-west-2 region. Note that I'm hosting the front-end only client not via the amplify add hosting
command, but by linking the git repos in the AWS Amplify console. Maybe this is the issue? For now, the workaround is simply to ignore the /amplify
folder entirely... Doing that allows it to deploy without issue.
Hey @raffibag :wave: if I understand correctly we have the app containing the backend in one repository that is not connected to the pipeline, whereas the frontend-only app does not contain the backend definition but is connected to the Amplify CI/CD pipeline for the Amplify App?
Thank you, @josefaidt. Both apps are connected to the Amplify CI/CD pipeline and are treated as discrete apps in the AWS Amplify console. The front-end only app is connected to the pipeline manually via linking the Git repos directly.
Thanks for clarifying @raffibag, does the second app have a custom buildspec file (amplify.yml
) or in the Amplify Console do you see a buildspec with a backend
job?
@josefaidt no buildspec file in the local directory, but the Amplify Console buildspec (under Build Settings) is:
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Again, please note that I deleted the /amplify
directory prior to pushing this to the corresponding git branch.
@josefaidt so after encountering some similar issues (and hacking a workaround), I think I've discovered the source of the problem.
In the main project (the one hosting the backend), I have set up three environments: dev
, test
, and main
. While test
and main
share the same appIds (d2y373y...
), the dev environment has an entirely different appId (d18xd0t...
). I think this happened when I initiated a new project a while back. The issue is when I run amplify pull from the frontend-only project and select the d2y373y...
appId, it always pulls the d18xd0t...
appId project. Subsequently, when I run amplify pull
from the front-end only cli, I receive an App d18xd0t... not found.
error.
This d18xd0t...
seems almost a phantom app... It keeps showing up, yet I can't seem to find it anywhere in the Amplify console - despite filtering through all the various regions. Any idea what could be causing this or, better yet, a possible resolution?
Hey @raffibag that is an interesting find! Does the main app have all three environments or are you currently unable to locate the dev environment and associated app?
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Not applicable
Amplify Categories
hosting
Environment information
Describe the bug
Per the Amplify Docs here (https://docs.amplify.aws/cli/teams/multi-frontend/) as of Feb 21, 2022:
For over a year and a half I've pulled our backend using the above instructions, however, recently when pulling the backend the action has been creating an
amplify
folder containingcli.json
andteam-provider-info.json
files.Further, when attempting to deploy the standalone frontend to Amplify, it is failing on backend build (because it's attempting to create the backend - which I don't want). To resolve the issue, I must manually delete the
amplify
folder from the project.Expected behavior
An
amplify
folder should not be generated onamplify pull
if answering "No" to the question:Do you plan on modifying this backend?
.Reproduction steps
amplify pull
from a standalone frontend projectAWS Profile
when prompted:Select the authentication method you want to use:
Please choose the profile you want to use
Which app are you working on?
dev
when prompted:Pick a backend environment
Visual Studio Code
when prompted:Choose your default editor
javascript
when prompted:Choose the type of app that you're building
react
when prompted:What javascript framework are you using?
Source directory path
:src
Distribution directory path
:build
Build command
:`npm run-script build
Start commaned
:npm run-script start
Note - at this stage, I'm receiving a
* Failed to sync UI components
error (<- this is also new)No
toAre you planning on modifying this backend?
On completing the above:
Added backend environment config object to your project.
Code Snippet
No response
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response