'sls remove' fails when S3 bucket contains objects
See original GitHub issueFor a given Serverless service where an S3 bucket has been created via the CloudFormation stack and some objects have been put in said bucket, running sls remove
fails to succeed because the buckets will not delete unless empty.
I believe the same process used to empty the deployment buckets should also be applied to any buckets created through CloudFormation.
What I’m not sure of is whether this should be implemented in core or relegated to a plugin.
- Serverless Framework Version you’re using: 1.17
Proposed solution (added later by maintainers)
- Introduce
provider.shouldEmptyBucketsOnRemove
config option, and--empty-s3-buckets
CLI param. If it’s on, removal process prior removing stack on CloudFormation should first find all S3 buckets (aside of deployment one) in a stack to be removed (we should rely on template downloaded from AWS, and not one generated by Framework), and empty them. - If none of the above is not set, and removal fails with bucket not empty error, then present meaningful error message suggesting above options
⚠️ ⚠️ ⚠️ If you’d like to address that, but you’re not sure how to tackle this, please ask for help, we’ll provide a specific implementation spec you can follow!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:15
- Comments:18 (11 by maintainers)
Top Results From Across the Web
Serverless S3 Remover - Serverless Framework: Plugins
Serverless S3 Remover. A serverless plugin to make s3 buckets empty before deleting cloudformation stack when ```sls remove```.
Read more >Remove S3 Buckets with the Serverless S3 Remover Plugin
In this video we dive into the Serverless S3 Remover Plugin and learn how to clean up our S3 buckets without adding additional...
Read more >Developers - 'sls remove' fails when S3 bucket contains objects -
For a given Serverless service where an S3 bucket has been created via the CloudFormation stack and some objects have been put in...
Read more >Top 10 Serverless Deployment Errors (and How to Fix Them)
This situation often arises when a deployed stack's subsequent deployment fails, along with the stack rollback or deletion. Deletes often fail ...
Read more >DeletionPolicy attribute - AWS CloudFormation
If a resource has no DeletionPolicy attribute, AWS CloudFormation deletes the ... For Amazon S3 buckets, you must delete all objects in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
--force
option would be nice! +1Thanks for opening @ryanmurakami and thanks @horike37 for jumping in 👍
We’ve discussed a related feature in https://github.com/serverless/serverless/issues/3679 and https://github.com/serverless/serverless/issues/1609.
IMHO Serverless shouldn’t auto-remove something for you since the bucket can contain some important data (same for DynamoDB and other services). However the
--force
option could be smth. we can add so that the user has to explicitly state that he wants to remove everything.