AWS Amplify: How to delete the environment, when resources are already partially deleted?

J. Hesters picture J. Hesters · Mar 14, 2019 · Viewed 12.5k times · Source

TL;DR: How to delete an amplify environment, when some resources of the service have been deleted manually in the console?

So, I took a course on egghead to learn the aws amplify CLI. Unfortunately, it doesn't teach you how to delete the environment (otherwise it's great though!). My google search back then said you will have to delete the resources manually. I tried (/did) that for the resources I used. I deleted the user account for the CLI (🤦🏻‍♂️), "deleted" the cognito user pool (it still shows up in amplify status), deleted the DynamoDB and the AppSync API (also still shows up).

Now as I mentioned when I run amplify status I get:

| Category | Resource name   | Operation | Provider plugin   |
| -------- | --------------- | --------- | ----------------- |
| Auth     | cognito559c5953 | No Change | awscloudformation |
| Api      | AmplifyTodoApp  | No Change | awscloudformation |

I wondered - since I thought I deleted them - do they still exist?

So I googled some more. Now it turns out there is also the command amplify delete which automatically deletes all resources associated with your amplify project. Since I deleted the account that I used for the project, that command throws:

The security token included in the request is invalid.

Is there any way I can delete these resources without the user? Are these resources even still online (since I manually deleted them and they do not show up in the console online - even in the CloudFront console)? Or will I have to delete my whole AWS account? I don't want to end up with a big bill one day for these resources.

EDIT: I also deleted the S3 bucket.

EDIT 2: So I managed to use another profile (by changing local-aws-info.json) so I don't get the security request failed error any more. Now I get the error:

Missing region in config

amplify status still yields the same response.

Answer

Yathi picture Yathi · Mar 15, 2019

amplify cli determines the status by diffing amplify/#current-cloud-backend and amplify/backend folder inside your project. So what you see when you run amplify status you see isn't accurate in your case.

If you have created multiple environments (in different regions) make sure that you delete them too. The easiest way to delete them if you can't use amplify delete is to go to cloud formation in the region where you have created the environment and deleting the root stack, which ensures that all the resources created by that stack are removed.

PS: The cli creates roles for auth and unauth users when initialized and creates policies for the resources (they don't cost anything if they exist). You could delete them if you don't want them hanging around.