aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.83k stars 823 forks source link

Pulling an env erases the previous one #11372

Open manu2504 opened 2 years ago

manu2504 commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

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

v12.22.12

Amplify CLI Version

10.4.0

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.

Nope.

Amplify Categories

auth

Amplify Commands

env

Describe the bug

When I pull an environment with amplify env pull --envName ..., the previous environment that was pulled on my project is removed, and replaced by the env just pulled (as shown by amplify env list or amplify/team-provider-info.json).

Expected behavior

All the envs pulled should be saved locally—an env pulled should not replace previous env pulled.

Reproduction steps

  1. Create an amplify project and select the default config
  2. Create a new env (amplify env add test)
  3. From a new folder, pull the amplify project (as a colleague would) amplify pull --appId ...
  4. Select again the default config, expect for: Do you plan on modifying this backend?, respond No
  5. List your current envs amplify env list. See that one env is listed (dev).
  6. Run amplify env pull --envName test
  7. Re-run amplify env list. See that only env is listed (test), and that dev is no more listed.

GraphQL schema(s)

```graphql # Put schemas below this line ```

Project Identifier

Running amplify diagnose --send-report triggers a bug:

$ amplify diagnose --send-report

Learn more at https://docs.amplify.aws/cli/reference/diagnose/
⠋ Creating Zip
File at path: '/Users/manu/sw-projects/lmad-locker/amplify/backend/backend-config.json' does not exist
✖ Creating Zip

Log output

``` # Put your logs below this line ```

Additional information

This bug is new to me since I upgraded to 10.4.0. Pulling new envs worked as expected previously.

josefaidt commented 2 years ago

Hey @manu2504 :wave: thanks for raising this! By chance when you pulled your project originally did you select "No" to "do you plan on modifying this backend?"

josefaidt commented 2 years ago

Closing due to inactivity

manu2504 commented 2 years ago

@josefaidt sorry for missing the previous comment—I selected "No" for"do you plan on modifying this backend?" (In fact, as specified in the original post)

josefaidt commented 2 years ago

Hey @manu2504 thanks for clarifying and apologies for missing that in the report! It appears we have two issues here, one being the issue where pulling an env overwrites the existing env when we choose not to modify the backend, and the second being diagnose not working in the event we choose not to modify the backend. I'll file a separate bug report for the latter.

The original issue seems related to https://github.com/aws-amplify/amplify-cli/issues/11066, where we would then be blocked on checking out existing local envs. I'm going to take a deeper look at this one

kevinxu3 commented 1 year ago

Any updates on this running into the same issue?

robvelor commented 1 year ago

So I just did a new clone of our amplify repo and come to find out:

1) amplify init -> always creates new env 2) amplify pull -> replaces the existing env (amplify env ls - only shows 1 env) 3) I can no longer delete the unneeded environment with amplify cli

This is with version 11.1.1