Cannot deploy/remove stack because S3 bucket is gone
See original GitHub issueI 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:
- Created 6 years ago
- Reactions:25
- Comments:30 (6 by maintainers)
Here is a workaround that’s been working for me without needing --force:
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.sls remove
(which should now complete successfully)Will be nice to have a proper fix soon… =)
vaya puta mierda de sls y plugins