# Serverless framework not deleting old API Gateway resource paths

**URL:** <https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, cloudformation, api-gateway\
**Created:** [June 30, 2021, 6:48pm UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450 "2021-06-30T18:48:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdullahali](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/abdullahali/32/5926_2.png) [@abdullahali](https://forum.serverless.com/u/abdullahali)\
**Post date:** [June 30, 2021, 6:48pm UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/1 "2021-06-30T18:48:45Z")

</div>

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:

```auto
functions:
  hello:
    handler: handler.hello
    events:
      - 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:

```auto
functions:
  hello:
    handler: handler.hello
    events:
      - 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](https://i.stack.imgur.com/owZIg.jpg)](https://i.stack.imgur.com/owZIg.jpg)

But when I look a `API > Resources` section, it only shows `/new` as I would expect [![enter image description here](https://i.stack.imgur.com/m5hsy.jpg)](https://i.stack.imgur.com/m5hsy.jpg)

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!

---

<div class="post-metadata">

**Author:** ![abdullahali](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/abdullahali/32/5926_2.png) [@abdullahali](https://forum.serverless.com/u/abdullahali)\
**Post date:** [June 30, 2021, 9:12pm UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/2 "2021-06-30T21:12:15Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![pgrzesik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pgrzesik/32/5054_2.png) [@pgrzesik](https://forum.serverless.com/u/pgrzesik)\
**Post date:** [July 1, 2021, 7:50am UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/3 "2021-07-01T07:50:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![abdullahali](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/abdullahali/32/5926_2.png) [@abdullahali](https://forum.serverless.com/u/abdullahali)\
**Post date:** [July 1, 2021, 8:32am UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/4 "2021-07-01T08:32:25Z")

</div>

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:

 ![Screenshot 2021-07-01 at 09.23.40](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/9/9feec84f84b3b71a44b20ce7f17fb2a8cb7822d6.png)

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

 ![Screenshot 2021-07-01 at 09.27.30](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/1/1cb93ff2098e6f09db3d0e10a196fcbfe9055807.png)

I can also still curl both endpoints too:

 ![Screenshot 2021-07-01 at 09.29.53](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/e/ebf05effee848460d9ea021e5c624447f6156717.png)

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:

 ![Screenshot 2021-07-01 at 09.30.22](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/f/fd7ec3e5cad2be021168a1d432afc6361b9d35cf.png)

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):

 ![Screenshot 2021-07-01 at 09.40.14](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/f/fc1ea7c4594fcb53a74fdb823d1e212d84690165.png)

---

<div class="post-metadata">

**Author:** ![abdullahali](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/abdullahali/32/5926_2.png) [@abdullahali](https://forum.serverless.com/u/abdullahali)\
**Post date:** [July 1, 2021, 10:40am UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/5 "2021-07-01T10:40:10Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![pgrzesik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pgrzesik/32/5054_2.png) [@pgrzesik](https://forum.serverless.com/u/pgrzesik)\
**Post date:** [July 2, 2021, 12:34pm UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/9 "2021-07-02T12:34:26Z")

</div>

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](https://github.com/serverless/serverless/issues) Thanks in advance 🙇‍♂️

---

<div class="post-metadata">

**Author:** ![abdullahali](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/abdullahali/32/5926_2.png) [@abdullahali](https://forum.serverless.com/u/abdullahali)\
**Post date:** [July 2, 2021, 3:04pm UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/10 "2021-07-02T15:04:02Z")

</div>

@pgrzesik thank you very much - I have [opened an issue](https://github.com/serverless/serverless/issues/9686) - please let me know if I can provide any more detail

---

<div class="post-metadata">

**Author:** ![pgrzesik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/pgrzesik/32/5054_2.png) [@pgrzesik](https://forum.serverless.com/u/pgrzesik)\
**Post date:** [July 5, 2021, 7:34am UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/11 "2021-07-05T07:34:01Z")

</div>

Thanks a lot 🙇‍♂️ I’ll be looking into that issue today

---

<div class="post-metadata">

**Author:** ![abdullahali](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/abdullahali/32/5926_2.png) [@abdullahali](https://forum.serverless.com/u/abdullahali)\
**Post date:** [July 5, 2021, 8:23am UTC](https://forum.serverless.com/t/serverless-framework-not-deleting-old-api-gateway-resource-paths/15450/12 "2021-07-05T08:23:49Z")

</div>

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