Serverless framework not deleting old API Gateway resource paths

I am having a weird issue where serverless seems to be keeping old lambda handler paths after doing a deploy on a fresh project

For example, this is my config:

    handler: handler.hello
      - http:
          path: /old
          method: GET

After I do a deploy, and I look on AWS, it correctly lists /old in the API > Stages section.

However, I then change the path:

    handler: handler.hello
      - http:
          path: /new   # this path has changed
          method: GET

And after I do a deploy, I now see both /old and /new in the API > Stages section enter image description here

But when I look a API > Resources section, it only shows /new as I would expect enter image description here

It seem like the only way to remove the /old paths is to do another deploy (even though the code does not change)

How can I get rid of the /old paths please?

This is a fresh project on the latest version of serverless

Any advice would be much appreciated!

@pgrzesik @buggy apologies for tagging you directly, but I was wondering if you can help me with this or let me know if I am using the correct keywords as I am unfamiliar with the terminology for this section of aws

Hello - does that persist after subsequent deployments? Could you check if that’s the case by fetching the stages e.g. via AWS CLI? Maybe it’s just some caching on the frontend side in the AWS console?

Hi @pgrzesik thanks for the quick reply!

Unfortunately, it does not look like it is frontend caching

For example:

If I view the stage documentation, I still see the old paths:

If I then do an AWS CLI call to export that documentation, I still see the old resource paths too:

I can also still curl both endpoints too:

The only way to remove these old resource paths is doing a a subsequent, forced deploy (where no code has changed) via serverless, or via the AWS console:

Also just to confirm, this is a completely new project that’s been created, so there shouldn’t be any odd plugins causing this issue (this is the full serverless.yml file below):

@pgrzesik I’ve been experimenting this morning, it looks like we need that second deploy for some reason

For example, this is what I am doing:

  1. add a /old route and deploy sls deploy --stage test -v - we now have /old routes
  2. changes the /old route to /new and deploy sls deploy --stage test -v - we now have /old and /new routes in the Stages area
  3. don’t change anything and deploy sls deploy --stage test -v --force - this now removes the /old route and only keeps the /new route

It looks like step 3 can be either:

  • a serverless deploy
  • a manual click on AWS Console Resources > Deploy API
  • an AWS CLI deployment: aws apigateway create-deployment --region eu-west-1 --rest-api-id xxxxxxxxxx --stage-name test

I think serverless should be doing that deploy automatically to remove the old resource paths, but it is not currently doing so

Thanks for extra details. Could you please report is as an issue (following the issue template - ideally with reproducible steps) here: Issues · serverless/serverless · GitHub Thanks in advance :bowing_man:

1 Like

@pgrzesik thank you very much - I have opened an issue - please let me know if I can provide any more detail

1 Like

Thanks a lot :bowing_man: I’ll be looking into that issue today

1 Like

Thank you so much :raised_hands: I’m more than happy to send extra screenshots or jump on a call to help