# Url Versioning with multiple serverless projects under the same API GW

**URL:** <https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539>\
**Category:** Serverless Framework\
**Created:** [September 14, 2020, 1:08pm UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539 "2020-09-14T13:08:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![berimbolo](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@berimbolo](https://forum.serverless.com/u/berimbolo)\
**Post date:** [September 14, 2020, 1:08pm UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539/1 "2020-09-14T13:08:31Z")

</div>

Hi,

I am looking for some help with an issue I am facing. I have built an API GW with terraform and I then retrieve the gateway ID in my serverless project, which is a rest API, part of the url scheme contains the version e.g `v1/resource` or `v1/resource/sub_resource`.

I have now started to add a second API at version 1 which is a separate microservice representing another entity type and I am facing an error as `v1` is already used by another stack.

Is there a way I can share the `/v1` portion to enable multiple serverless projects to be deployed into the same API gateway? Such that roll forwards some time period and I might have:

`v1/person`  
`v2/person`  
`v1/user`  
`v2/user`

The above is just an arbitrary example of what I would like to do, with two serverless projects `person` and `user`, deployed into one API gateway.

Is something like this possible?

---

<div class="post-metadata">

**Author:** ![syammohanp](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@syammohanp](https://forum.serverless.com/u/syammohanp)\
**Post date:** [September 14, 2020, 2:14pm UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539/2 "2020-09-14T14:14:04Z")

</div>

Hello,  
You can solve this with GraphQL, apollo server. Instead of API Gateway, you can use Appsync and it has out of support for GraphQL.  
Regards  
Syam

---

<div class="post-metadata">

**Author:** ![Dicondur](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@Dicondur](https://forum.serverless.com/u/Dicondur)\
**Post date:** [September 16, 2020, 5:32am UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539/3 "2020-09-16T05:32:42Z")

</div>

Are you not able to use v1 as a path to represent the various versions?

Ideally you want to have stage variable in API Gw to hold the version. Dont know how this is implemented with terraform. Will be interested to know.

> **[Using API Gateway stage variables to manage Lambda functions | Amazon Web...](https://aws.amazon.com/blogs/compute/using-api-gateway-stage-variables-to-manage-lambda-functions/)**
>
> Ed Lima, Cloud Support Engineer There’s a new feature on Amazon API Gateway called stage variables. Stage variables act like environment variables and can be used to change the behavior of your API Gateway methods for each deployment stage; for...

---

<div class="post-metadata">

**Author:** ![berimbolo](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@berimbolo](https://forum.serverless.com/u/berimbolo)\
**Post date:** [September 16, 2020, 8:04am UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539/4 "2020-09-16T08:04:23Z")

</div>

Hi Dicondur,

“Are you not able to use v1 as a path to represent the various versions?” I think if it were a single serverless project then I would be ok, but as I have multiple micro repos and each holds a serverless project in its own right when I then try to use the `v1` identifier in the URL cloud formation complains that is already owned by another stack, so the first project deployed into API gateway will be fine, whatever one it happens to be, subsequent deployments will then fail.

I will look at what you have referenced and see if there is a way to do this.

---

<div class="post-metadata">

**Author:** ![berimbolo](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@berimbolo](https://forum.serverless.com/u/berimbolo)\
**Post date:** [September 16, 2020, 8:09am UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539/5 "2020-09-16T08:09:38Z")

</div>

I dont think stage variables will help here because this is an issue with actually creating a new endpoint in a different serverless project, when an endpoint with the version has already been created.

I had read that some people create a serverless project per function, so how can this work? If I have a single serverless project per function, and I have a rest resource, lets call it `person`, and in my first project I attach `/person/{id}/cars` from what I can see it wont be possible in the second serverless project to attach `/person/{id}/addresses` due to the cloudformation deployment failing when the second deployment tries to use the `/person` identifier.

---

<div class="post-metadata">

**Author:** ![Dicondur](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@Dicondur](https://forum.serverless.com/u/Dicondur)\
**Post date:** [September 17, 2020, 4:04pm UTC](https://forum.serverless.com/t/url-versioning-with-multiple-serverless-projects-under-the-same-api-gw/12539/6 "2020-09-17T16:04:21Z")

</div>

Haa I see, have you looked at nested Stacks. [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html)
