Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple serverless files sharing the same api gateway

I am using serverless framework to build a REST API. I have reached the 200 limit stack size and read about the multiple approaches to circumvent it. The most common approach is to split the stacks in a "microservices fashion", where each stack handles a particular set of resources that make sense together.

Because of how serverless works each of those services would create a new api gateway for itself and then, as explained in this blog post, a shared domain can be setup between them so all endpoints can be accessed through the same base url.

Even though this is a valid solution I would really like to be able to work with a single API gateway resource shared between the different stacks, so I don't have to decide upfront a separation of concerns between the different components of my api. Is this possible?

like image 380
Jesuspc Avatar asked Feb 13 '18 18:02

Jesuspc


People also ask

Is API gateway is Serverless?

API Gateway supports containerized and serverless workloads, as well as web applications.

Can Lambda call API gateway?

You can create a web API with an HTTP endpoint for your Lambda function by using Amazon API Gateway. API Gateway provides tools for creating and documenting web APIs that route HTTP requests to Lambda functions. You can secure access to your API with authentication and authorization controls.

Can an API be Serverless?

Among numerous alternative ways of creating an API, serverless is one approach gaining popularity during the last few years because of its cost efficiency, scalability, and relative simplicity.

What is the difference between AWS Gateway API and lambda?

AWS API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. Lambda is function as a service(FAAS) product of AWS. The combination of these two services is amazing and it is slowly replacing the traditional backend.


1 Answers

This feature has been recently added to serverless. Documentation is available here.

Essentially the apiGateway to be used in a serverless file can be configured through a config option inside "providers".

provider: 
  ...
  apiGateway:
    restApiId: xxxxxxxxxx # REST API resource ID. Default is generated by the framework
    restApiRootResourceId: xxxxxxxxxx # Root resource, represent as / path

This feature was introduced by this pull request and is available from serverless version 1.26.

like image 102
Jesuspc Avatar answered Oct 02 '22 18:10

Jesuspc