API gateway: same base URLs for my APIs?

Hi,

I’ve architected some microservices exposed as APIs on amazon API Gateway.
Every API is a different serverless project (user api, auth api, etc.).
The problem I face is that every deployed API has a different base URL.

Example:

Auth API https://12323232.execute-api.eu-central-1.amazonaws.com/dev
User API https://5555553.execute-api.eu-central-1.amazonaws.com/dev

My question is:

Can I use the same base URL for all my APIs?
That is:
https://fixedbaseurl/dev/users
https://fixedbaseurl/dev/auth

instead of
https://12323232.execute-api.eu-central-1.amazonaws.com/dev/auth
https://5555553.execute-api.eu-central-1.amazonaws.com/dev/users

Here is more info:

http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html
(see section Base Path Examples of API Mappings for a Custom Domain Name)

It would be great if this could be automated. I don’t know if there any other solution.

Hi,

I am facing exactly same issue (I have 15 microservices at the moment) and I can tell what you try to achieve is not possible with serverless at the moment.

Even if you would be able to pass same base URL for all your APIs this would basically remove all your previous changes from other serveless services. Currently when you deploy API Gateway through serverless it basically replace previous API Gateway changes so if you have 2 serverless projects and you deploy auth and then user to api gateway you will end up only with users endpoints no auth endpoints because serveless doesn’t know anything about your endpoints from auth project.

I spoke with @flomotlik about this issue in London Serveless conf and they are actually working on solution as this is a pain for people that try to develop medium or large projects with many services and endpoints. My understanding is that in the future you should be able to create new serverless project just for api gateway where you specify all endpoints and function names (you don’t want to hard code the function names and instead this value should come from output of other serverless projects e.g during the CI deployment).

If you can’t wait till this feature will be add to serveless framework I would suggest to use cloudfromation and swagger for now.

Hi @martinmicunda,
Than you for your message.
Could you give me some more detail about do it by using cloudformation and swagger?
I suppose cloudformation templates generated by serveless could be useful…

@endymion here are a few resources that might help you to start

https://sookocheff.com/post/api/deploying-swagger-to-api-gateway/
http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html
https://www.jayway.com/2016/09/18/introduction-swagger-cloudformation-api-gateway

Could you setup one API GW to proxy all of the other API GW’s?