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.

Cannot deploy/remove stack because S3 bucket is gone

See original GitHub issue

I just ran into a situation where sls remove (1.17.0) failed to remove my service, because a CloudFormation resource was still updated by Amazon and the stack could not be removed. This totally makes sense, but my problem is that serverless/CloudFormation already deleted everything from S3 and now I’m stuck with a service that neither can be deployed nor removed because the S3 bucket does not exist anymore.

I’m fine if this is just based on my weird edge-case or on the custom CloudFormation resources and there is nothing you can do to prevent this. But a more specific error message than The specified bucket does not exist might be useful 😉

After deleting the Stack manually using the AWS Console I can deploy the service again. Maybe this is something that could be added doing with sls remove --force ?

Console Outputs

$ > $(npm bin)/sls deploy
…
Serverless: Checking Stack update progress...
Serverless: Stack update finished...
$ > $(npm bin)/sls remove
Serverless: Getting all objects in S3 bucket...
Serverless: Removing objects in S3 bucket...
Serverless: Removing Stack...
Serverless: Checking Stack removal progress...
Serverless: Deployment failed!
 
  Serverless Error ---------------------------------------
 
  An error occurred while provisioning your stack: CustomTableA - Attempt to change a resource which is still in use: Table: custom-table-A is in the process of being updated..

State where neither deploy nor remove work anymore

$ > $(npm bin)/sls remove
Serverless: Getting all objects in S3 bucket...
 
  Serverless Error ---------------------------------------
 
  The specified bucket does not exist
$ > $(npm bin)/sls deploy
Serverless: Packaging service...

  Serverless Error ---------------------------------------
 
  The specified bucket does not exist

Solution implementation proposal

(Added by maintainers)

Ensure that bucket does not exist error does not trigger exception. Instead removal process should continue with stack removal

It can be fixed here: https://github.com/serverless/serverless/blob/c864fbd4826de27d2796e394b0a100c8d3add33e/lib/plugins/aws/remove/lib/bucket.js#L52-L53 If either this.listObjects or this.deleteObjects fails with bucket does not exist error. ignore such error silently

It might be that it’s not sufficient for some cases. Ideally then we should force removal of a stack and eventually list all resources that could not have been removed

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:25
  • Comments:30 (6 by maintainers)

github_iconTop GitHub Comments

46reactions
jrfarrantcommented, Jun 14, 2019

Here is a workaround that’s been working for me without needing --force:

  1. Run sls deploy to generate an error message like: Serverless Error --------------------------------------- The serverless deployment bucket “myapp-#########” does not exist. Create it manually if you want to reuse the CloudFormation stack “myapp”, or delete the stack if it is no longer required.
  2. Manually create an S3 bucket called “myapp-#########” - all settings default are fine.
  3. Run sls remove (which should now complete successfully)

Will be nice to have a proper fix soon… =)

42reactions
lasserfoxcommented, Aug 14, 2019

vaya puta mierda de sls y plugins

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I delete an AWS CloudFormation stack that's stuck in ...
The stack fails because the security group resource can't be deleted. To delete the stack, you must retain that dependent resource.
Read more >
How to delete the CloudFormation stack - Serverless Forums
Hi All,. I deployed my first SLS aws lambda project successfully, which created the 2 S3 buckets automatically. 1 for deploying the lambda...
Read more >
Can't Delete Empty S3 Bucket - Stack Overflow
1. Open the Amazon S3 Management Console 2. Select the Elastic Beanstalk storage bucket. 3. Choose Properties. 4. Choose Permissions. 5. Choose Edit...
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 >
Error with Serverless Deployment - DEV Community ‍ ‍
Error: Deployment bucket has been removed manually. When you try to serverless deploy and you see this error on your terminal.
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