aws-amplify / aws-amplify/amplify-cli

Amplify add api request causes issue saying "There was an error adding the API resource", File at path: '/Users/admin/Documents/prfinal/amplify/backend/amplify-meta.json' does not exist

Open
#10,635 4 comments 0 reactions 0 assignees View on GitHub
bug ops-errors p2 platform
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [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.

### How did you install the Amplify CLI?

npm

### If applicable, what version of Node.js are you using?

v16.15.0

### Amplify CLI Version

8.5.1

### What operating system are you using?

MAC

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

no manual changes made

### Amplify Categories

auth, storage, api, hosting, notifications, interactions

### Amplify Commands

add

### Describe the bug

We are trying to implement the Multi frontend Feature of amplify (https://docs.amplify.aws/cli/teams/multi-frontend/) as we have multiple repo with multi front end (Mobile app repo, Admin panel repo etc).

We have successfully installed, added auth , created schemas & added GraphQL api and pushed it into our Main Amplify Frontend Repo 1, now when we go to our other front end (Repo 2) and we are trying to connect / Sync it with our Main Amplify Repo or Repo 1 by giving "Amplify Pull" , the request gets successfully executed after we select the Main Amplify Repo 1's name. Now when we give the command "amplify add api" & after Selecting GraphQL i get the following error,

🛑There was an error adding the API resource
🛑 File at path: '/Users/admin/Documents/org/prfinal/amplify/backend/amplify-meta.json' does not exist

admin@admin-MacBook-Pro prfinal % amplify pull

? Select the authentication method you want to use: AWS profile

For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

? Please choose the profile you want to use admin
? Which app are you working on? d2g5po0fxcksn9
? Pick a backend environment: dev
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: build
? Build Command: npm run-script build
? Start Command: npm run-script start
? Do you plan on modifying this backend? No

Added backend environment config object to your project.
Run 'amplify pull' to sync future upstream changes.

admin@admin-MacBook-Pro aum % amplify add api
? Select from one of the below mentioned services: GraphQL
🛑 There was an error adding the API resource
🛑 File at path: '/Users/admin/Documents/org/prfinal/amplify/backend/amplify-meta.json' does not exist

### Expected behavior

For the Question Do you plan on modifying this backend ?
We have to give 'No' because we don't want the backend to be modifiable.

Hence once we give amplify pull from another Repo 2 and once we give "amplify add api" then after that GraphQL is selected, the backend GrahpQL data must sync / get connected with the main Amplify Repo 1 and must be able to easily pull the data everytime we pull.

We need to achieve Multi Front End Amplify GraphQL sync across various Repos.

### Reproduction steps

Make sure to follow all pre requisites before starting
https://docs.amplify.aws/cli/start/install/
create users & access roles.

1: Create & configure an amplify project name it repo 1 with sample schema & deploy it
2: Create your graphQL API in Repo 1 & deploy it
3: Add Authentication

Now let's connect the Repo 1 you created to a different frontend Repo 2.

Go to your Amplify Console.
Click on the app you're working on.
Click "Backend Environments".
Click "Edit Backend".
Copy the line of code that looks like this:
amplify pull --appId ************* --envName *******
and run that command in your new frontend environment.

use the below settings:

admin@admin-MacBook-Pro prfinal % amplify pull

? Select the authentication method you want to use: AWS profile

For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

? Please choose the profile you want to use admin
? Which app are you working on? d2g5po0fxcksn9
? Pick a backend environment: dev
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: build
? Build Command: npm run-script build
? Start Command: npm run-script start
? Do you plan on modifying this backend? No

Added backend environment config object to your project.
Run 'amplify pull' to sync future upstream changes.

admin@admin-MacBook-Pro aum % amplify add api
? Select from one of the below mentioned services: GraphQL
🛑 There was an error adding the API resource
🛑 File at path: '/Users/admin/Documents/org/prfinal/amplify/backend/amplify-meta.json' does not exist

Important: Choose ‘No’ when asked if you want to modify or add new categories to your backend.

You will receive above error. This is the issue.

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

The folder Backend itself is missing in repo2 after we pull. we are able to see only amplify->hooks folder in our repo 2.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the sequence using `amplify pull` followed by `amplify add api`, focusing on the missing `amplify/backend/amplify-meta.json` reported in the issue. Trace the CLI entry points for those commands and verify whether a read-only multi-frontend project is expected to support adding an API; done means the intended workflow either succeeds or reports a clear, documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, node.js, typescript
Domain
api, backend-api-design, cli, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.