Apigateway deleted and deploy fails

My team has a set of lambdas as an API. The Apigateway set of endpoints was removed, we tried redeploying but now serverless throws an error in the process. Is it because somehow it was linked to that set of Apigateway endpoints? If that is the case, is there a way for Serverless to generate again them (preferrably with the same URL)?

It really depends how the API GW was removed.

If it was removed manually then you can create a new API GW by

  1. Comment out every reference to the API GW in your serverless.yml. That’s all of the http events, authorizers, anything in the resources sections, etc. The CloudFormation template created by Serverless needs to have no references to the API GW.
  2. Deploy your project. This will remove the API GW from your CloudFormation stack.
  3. Undo the changes made in step 1.
  4. Deploy your project.

This will create a new API GW.

If you were using the API GW URL assigned by AWS then there is no way to get that URL back.

Hi,

Following way will not retrieve your api gateway url but it will help you redeploy.

  1. Go to cloudformation in aws console.
  2. Search for your function here.
  3. select it and delete your function template.
    (It might not delete successfully first time. Try deleting it again, select a checkbox on the popup )
  4. Do serverless deploy again.

Your api should get deployed properly.

1 Like