serverless: The bucket you tried to delete is not empty.
This is a (Bug Report)
Description
When trying to deploy a lambda function with an s3 bucket based trigger, the following error was shown.
Serverless Error ---------------------------------------
An error occurred: S3BucketNylndatestings - The bucket you tried to delete is not empty.
For bug reports:
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (24.49 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.......
Serverless: Operation failed!
Serverless Error ---------------------------------------
An error occurred: S3BucketNylndatestings - The bucket you tried to delete is not empty.
The following was the yml setu used.
service: aws-nodejs
plugins:
- serverless-offline
- serverless-plugin-existing-s3
provider:
name: aws
stage: dev
region: us-east-1
profile: default
runtime: nodejs6.10
memorySize: 256
timeout: 30
environment:
iamRoleStatements:
- Effect: "Allow"
Action:
- "sns:*"
Resource: "*"
- Effect: "Allow"
Action:
- "s3:*"
Resource:
Fn::Join:
- ""
- - "*"
custom:
ACCOUNT_ID: "338135766024"
MEDIA_BUCKET: "nylndamedia-dev-bucket"
functions:
cool:
handler: handler.cool
events:
- existingS3:
bucket: nylnda-testing-s3
# bucket: nylndamedia-dev-bucket
event: s3:ObjectCreated:PUT
rules:
- prefix: Reaction/Videos/
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 33 (7 by maintainers)
This issue is present in version 1.43.0
any news?
The issue is still present in
1.66.0!The issue is also present in version 1.54.0
Got the same issue when I’ve added provider.deploymentBucket.name to serverless.yml
Upd. upgrade serverless to 1.39.1 version solved the problem
Thanks for providing more insights @bityob - I’ve managed to reproduce it and it seems like the issue here is that the
deleteObjectsdoes not throw on errors but rather returns a valid response and includes errors there. I will prepare a PR with a fix that provides more actionable error information.In my case I cannot delete S3 bucket @vsuzdaltsev 😦
The issue is still present in
1.67.0In my case, the serverless deployment bucket had a lot of objects worth closer to 100 GB, and S3 won’t allow deleting a bucket unless you empty it out. Emptying a bucket is a bit time-consuming activity which I ended up doing manually.
Still happens in 3.0.1 version
Any known workaround without deleting the bucket?
Hi @SandeepVattapparambil . The
existingS3event type seems to be added by theserverless-plugin-existing-s3plugin. I think the issue is related with that and there is a bug in case of removing the service. Serverless core does not handle that, so please check if there is already an issue in the plugin’s GitHub repository.