serverless: Unable to remove serverless stack that doesn't use API gateway...

Problem:

  • Step 1: Deploy a (simple?) stack that has no events from API Gateway, and it will not create an API Gateway as part of the CloudFormation stack (because it doesn’t need it). Eg: use an event source, such as S3.
  • Step 2: Try to serverless remove and it reports an error that says Resource ApiGatewayRestApi does not exist for stack stackname-goes-here.

Notes:

There’s nothing wrong with the CloudFormation in this instance… I can jump onto the AWS Console and grab the CF and click Delete Stack and it deletes the stack perfectly. I heard that in some of the recent releases of Serverless you added various pre-flight checks to save from a failing CloudFormation change. But in the case of removal, you probably want to skip these pre-flight checks, and merely check if the name of the CloudFormation stack exists, and if it does, just remove it.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

In my case, I have not http events but I had declared apiKeys under provider. I solved this problem, by removing the apiKeys declaration and then running sls remove.

I managed to run into this when using an external RestApi resource and defining an API key:

service: service-a

provider:
  apiGateway:
    restApiId: xxxxxxxxxx
  apiKeys:
    - myApiKey

Deployment succeeds, but removal fails because the code expects the ApiGatewayRestApi resource to be present in the serverless stack.

@pmuens Could we please reopen this?

Closing this issue since it’s quite old and there are some solutions in the issue thread.