Url Versioning with multiple serverless projects under the same API GW

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?

1 Like

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

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.

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.

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.

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