On remove of "single-page-app" and "static-website": S3 Bucket deletion is triggered, when the bucket is not yet empty
InvisibleKind opened this issue · 1 comments
Description
Recently an error startet to appear, which was not there before: whenever a Stack deletion is triggered through serverless remove
the lift still tries to empty the S3 bucket of the single-page-app
or static-website
construct
But for some reason doesn't wait until the cleanup is finished and triggers the removal of a Bucket itself, which results in an error like:
Resource handler returned message: "The bucket you tried to delete is not empty (Service: S3, Status Code: 409, Request ID: -, Extended Request ID: -)"
The whole output (omitting the hashes and project info):
npx serverless remove --stage=poc
Removing fe-service from stage poc (eu-central-1)
Emptying S3 bucket 'fe-serv-buildpublicbucket' for the 'build_public' static website, else CloudFormation will fail (it cannot delete a non-empty bucket)
Environment: darwin, node 20.11.0, framework 3.38.0 (local), plugin 7.2.0, SDK 4.5.1
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
DELETE_FAILED: buildpublicBucket (AWS::S3::Bucket)
Resource handler returned message: "The bucket you tried to delete is not empty (Service: S3, Status Code: 409, Request ID:-, Extended Request ID: -)" (RequestToken: -, HandlerErrorCode: GeneralServiceException)
Serverless Framework: 3.38.0
Lift: 1.28.1
Triggering the same remove command second or third time will empty the bucket and remove the stack completely.
Removing the files from the bucket using AWS Console works without issues.
Average number of files in the S3 Bucket: 1175 objects, 63.1 MB
How to Reproduce
Not sure, what the exact scenario is, but I assume, that you need a project with 1k+ files, deployed either as "single-page-app" or as "static-website".
Additional Information
No response