10

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?

1 Answer 1

10

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.