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 deleting wrong environment after 'amplify env remove [env-name]' #13534

Closed
2 tasks done
Andrea-Vigano opened this issue Jan 14, 2024 · 7 comments
Closed
2 tasks done
Labels
multienv Issues tied to multiple environment feature in the CLI pending-response Issue is pending response from the issue author pending-triage Issue is pending triage

Comments

@Andrea-Vigano
Copy link

How did you install the Amplify CLI?

npm

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

21.2.0

Amplify CLI Version

12.8.2

What operating system are you using?

Mac M1

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

No manual changes made

Describe the bug

I created a new environment from the cli with amplify env add and after failing to push it to the cloud (it was failing, which makes me think the creation was not successful in the first place) I deleted it with amplify env remove [env name].

The command deleted the wrong environment in the cloud, while locally I still get it when running amplify env list.

Trying to push the env back to the cloud fails because the cli cannot find the deployment buckets in S3.

Expected behavior

CLI should correctly manage environments consistently or at least not delete the wrong environment.

Reproduction steps

My environment got deleted so I have not chance to check which features of my project where causing issues while creating new environments

Project Identifier

db716a04fee8b7312e086f021e6d234e

Log output

amplify add env

Note: It is recommended to run this command from the root of your app directory
? Enter a name for the environment analytics
Using default provider  awscloudformation
⠋ Building resource api/StampyAlpha✅ GraphQL schema compiled successfully.

Edit your schema at [...] or place .graphql files in a directory at [...]
✔ Initialized provider successfully.
✅ Initialized your environment successfully.
✅ Your project has been successfully initialized and connected to the cloud!
Some next steps:

[...]

amplify env remove analytics

✔ Are you sure you want to continue? This CANNOT be undone. (This will delete 'analytics' environment of the project from the cloud) (y/N) · yes
⠋ Deleting resources from the cloud. This will take a few minutes.
Deleting env: analytics.
⠹ Deleting resources from the cloud. This will take a few minutes.BackendEnvironment analytics does not exist.
✔ Successfully removed environment from the cloud
✅ Successfully removed environment from your project locally

Additional information

No response

Before submitting, please confirm:

  • 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.
@Andrea-Vigano Andrea-Vigano added the pending-triage Issue is pending triage label Jan 14, 2024
@Andrea-Vigano
Copy link
Author

Also running amplify pull gives weird behaviour as I get this screen while authenticating from the browser. Selecting staging just reloads the same page.

Screenshot 2024-01-14 at 19 17 03

@ykethan
Copy link
Member

ykethan commented Jan 15, 2024

Hey @Andrea-Vigano, thank you for reaching out. From the log output provided the create and delete of analytics env was successful. Could you provide us the error message that occurred on push? additionally, could check the team-provider-info.json and local-aws-info.json if the analytics env is currently listed.

@ykethan ykethan added multienv Issues tied to multiple environment feature in the CLI pending-response Issue is pending response from the issue author labels Jan 15, 2024
@Andrea-Vigano
Copy link
Author

I don't know where to find that information in team-provider-info.json. All the values I have are still referencing resources from the staging env. Also I don't know were to find the local-aws-info.json file.

I was not getting errors while pushing analytics at first. The cli was just saying that no changes were being detected. After modifying a random resource and trying to push I was getting an error. I don't have the actual message but it was related to the fact that everything was still pointing to the staging env.

Right now on every command I run on the cli I get this error:

🛑 File at path: '/Users/andrea/WebstormProjects/stampy/amplify/#current-cloud-backend/amplify-meta.json' does not exist

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Jan 16, 2024
@Andrea-Vigano
Copy link
Author

It may be useful for you to know that I had created an analytics env already from the console, but I then deleted it after duplication was failing.

@ykethan
Copy link
Member

ykethan commented Jan 16, 2024

@Andrea-Vigano From the information provided, if you only observe the references to staging env in the team-provider-info.json and the Amplify console it appears the env was removed but a reference to the env might still be present in the local-aws-info.json file. The local-aws-info.json can be found under the amplify/.config folder, which may be hidden in VsCode; in the project root .vscode/setting.json folder set "amplify/.config": false,.
if you observe a reference to the env in the file, remove the analytics block, then run amplify env list to verify.

🛑 File at path: 'stampy/amplify/#current-cloud-backend/amplify-meta.json' does not exist

Could you check the Amplify S3 deployment bucket on the AWS console, the bucket name should be in the format: amplify-<app-name>-<env name>-<random>-deployment. In the bucket, could you download the #current-cloud-backend and verify it it does contain the amplify-meta.json

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Jan 16, 2024
@josefaidt
Copy link
Contributor

Closing due to inactivity

@josefaidt josefaidt closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
Copy link

github-actions bot commented Feb 2, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multienv Issues tied to multiple environment feature in the CLI pending-response Issue is pending response from the issue author pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

3 participants