"amplify remove env" fails with "Cannot read property 'message' of null"
See original GitHub issueDescribe the bug I have multiple environments. Most of them are in the same account / profile (called ‘dev’). I have created one with a different profile (called ‘test’). When I try and remove that I get
amplify env remove testse
Scanning for plugins...
Plugin scan successful
? Are you sure you want to continue? This CANNOT be undone. (This would delete 'testse' environment of the project from the cloud) Yes
⠋ Deleting resources from the cloud. This may take a few minutes...
Deleting env:testse
⠸ Deleting resources from the cloud. This may take a few minutes...
Error in deleting env:testse
✖ remove env failed: Cannot read property 'message' of null
Cannot read property 'message' of null
TypeError: Cannot read property 'message' of null
at AmplifyToolkit.removeEnvFromCloud [as _removeEnvFromCloud] (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/remove-env-from-cloud.js:22:26)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/env/remove.js:44:11)
at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/commands/env.js:27:9)
at Object.executeAmplifyCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/index.ts:161:3)
at executePluginModuleCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/execution-manager.ts:161:3)
at Object.executeCommand (/usr/local/lib/node_modules/@aws-amplify/cli/src/execution-manager.ts:25:5)
at Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/src/index.ts:84:5)
I tried this multiple times with the same response. Removing an environment on the profile ‘dev’ works.
amplify env remove develop
? Are you sure you want to continue? This CANNOT be undone. (This would delete 'develop' environment of the project from the cloud) Yes
⠋ Deleting resources from the cloud. This may take a few minutes...
Deleting env:develop
✔ Successfully removed environment from the cloud
Successfully removed environment from your project locally
I guess this has something to do with some profile being saved wrongly in an autogenerated file?
Amplify CLI Version 4.24.3 and 4.25.0
To Reproduce I have not tried but I assume:
amplify init with aws ‘devProfile’ amplify push git checkout -b test amplify init with aws ‘testProfile’ amplify push
amplify env checkout dev amplify env remove test
Expected behavior Expecting it to remove the environment or at least tell me what the error is.
Desktop (please complete the following information):
- OS: Mac 10.15.5
- Node Version. v14.4.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14 (5 by maintainers)
As @bolenc explain this is because the environment checked out use a profile different than the environment you are trying to delete. Just edit the file amplify/.config/local-aws-info.json and temporarily change the value profile of the current env to the one you need to use for deletion. Once done the command
amplify env remove XXX
will work.That being said it is not convenient for the users and the Amplify team should make the fix automatic.
Hey bot, this issue is still occuring