mlevit / aws-auto-cleanup

Programmatically delete AWS resources based on an allowlist and time to live (TTL) settings
MIT License
495 stars 54 forks source link

serverless remove fails when trying to delete a non empty S3 bucket #28

Closed reynico closed 5 years ago

reynico commented 5 years ago
mba:aws-auto-cleanup nico$ serverless remove
Serverless: Getting all objects in S3 bucket...
Serverless: Removing objects in S3 bucket...
Serverless: Removing Stack...
Serverless: Checking Stack removal progress...
.......
Serverless: Operation failed!
Serverless: View the full error output: https://us-east-2.console.aws.amazon.com/cloudformation/home?region=us-east-2#/stack/detail?stackId=auto-cleanup-production

  Serverless Error ---------------------------------------

  An error occurred: ResourceTreeBuckett - The bucket you tried to delete is not empty (Service: Amazon S3; Status Code: 409; Error Code: BucketNotEmpty; Request ID: 67617758934444FC; S3 Extended Request ID: HDY+1eCAEY8Ei2tmf2ufRlRFtnd0pmvVYa/4wiAGCMH+mOmH7Eq/rGa1zRVXt4pOLElsxmJEzYk=).

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     OS:                     darwin
     Node Version:           11.12.0
     Serverless Version:     1.41.1
ghost commented 5 years ago

Hey @reynico, looks like this isn't supported by Serverless or CloudFormation itself. However this was opened as an issue (https://github.com/serverless/serverless/issues/3928) and closed with the resolution that someone had already made a Serverless plugin to deal with it: https://github.com/sinofseven/serverless-s3-remover

When I have time I'll add the plugin to prevent these errors from coming up again. For now, just empty the bucket via the AWS Console manually and then run serverless remove.