question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'sls remove' fails when S3 bucket contains objects

See original GitHub issue

For 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:open
  • Created 6 years ago
  • Reactions:15
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

15reactions
horike37commented, Jul 12, 2017

--force option would be nice! +1

9reactions
pmuenscommented, Jul 12, 2017

Thanks for opening @ryanmurakami and thanks @horike37 for jumping in 👍

I believe the same process used to empty the deployment buckets should also be applied to any buckets created through CloudFormation.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found