amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Deleting Amplify App Doesn't Cleanup Backend Host or S3

Open tjohnwu opened this issue 1 year ago • 5 comments

Before opening, please confirm:

  • [X] I have checked to see if my question is addressed in the FAQ.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting 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.

App Id

drkws8j6x3l0s

AWS Region

us-east-1

Amplify Hosting feature

Backend builds

Describe the bug

We use trunk based development (https://trunkbaseddevelopment.com/) which means we cut a new branch every week to deploy to production (release/0.xx.xx).

Every week we cut a new branch, deploy it to amplify, and then delete the old branch.

When we delete the old branch from amplify we have found that the backend environments & s3 buckets do not delete along with them.

Here is an example s3 bucket that did not delete 97o5sek-ojihlje when I removed the branch. This would only be a minor annoyance if it just accumulated but S3 has a bucket limit and we hit it quite often when deploying test branches or release branches.

Why does Amplify not automatically delete the backend environments & s3 buckets associated to an Amplify app?

Expected behavior

The entire aws footprint of an amplify project is deleted when the project is deleted.

Reproduction steps

  1. Create an Amplify Project
  2. Hook up a branch with SSR
  3. Delete the branch
  4. Notice that S3 buckets & backend still remain

Build Settings

No response

Log output

# Put your logs below this line


Additional information

No response

tjohnwu avatar Oct 31 '22 19:10 tjohnwu

Hi @tjohnwu 👋🏽 we are working on understanding this behavior but we have not been able to reproduce this issue thus far. Disconnecting the branch via the console or even deleting the branch via the AWS CLI both remove the SSR resources associated with the branches. Do you know when this issue started for you? How are you deleting the branches?

Also, please try using the aws amplify list-branches --app-id <value> command to ensure none of the older branches still exist. https://docs.aws.amazon.com/cli/latest/reference/amplify/list-branches.html

ghost avatar Nov 01 '22 22:11 ghost

The issue is still happening now and has been happening for a while (I am unsure when it started).

I tried aws amplify list-branches --app-id <value> and it does not display old branches.

The way I am disconnecting branches is by going to General > Branches > Select a Branch > Action > Disconnect Branch in the Amplify Console.

I just disconnected another branch in my amplify project and the backend environment associated is still not deleted.

tjohnwu avatar Nov 02 '22 05:11 tjohnwu

Hi, I am seeing the same issue with PR Preview after the PRs are merged, the backend env, and the S3 buckets are not being properly deleted. Same thing with the list-branches command, it is only showing the main branch, and the 2 currently open PRs.

I only found out today because we hit the quota limit on S3 buckets. Manually emptying and deleting buckets is very monotonous and time consuming.

djorgji avatar Nov 16 '22 20:11 djorgji

I am also facing this same issue. @hloriana it is quite simple to reproduce actually. Just create a branch that has configured Amplify. Delete branch and you will notice that resources in S3 remain. I am now facing with a task where I have to delete them manually in order to free up space... Quite tedious tbh...

ssbarbee avatar Nov 28 '22 16:11 ssbarbee

Yes, this is simple to reproduce. It's the base functionality, it seems.

austinschrader avatar Mar 08 '24 01:03 austinschrader