Serverless framework v1 - multiple resources in one service

前端 未结 3 1906
清歌不尽
清歌不尽 2021-01-20 14:33

I have two resources, games and players, both have crud functions. Are these supposed to be in the same serverless service? I would like to separate them, but how do I then

3条回答
  •  甜味超标
    2021-01-20 14:57

    One way of doing what you want is to use serverless to deploy the lambdas but to manually set API Gateway to link the endpoints to the lambdas.

    There is a restriction in serverless stated here: https://serverless.com/framework/docs/providers/aws/guide/services/

    Where it states:

    Currently, every service will create a separate REST API on AWS API Gateway. Due to a limitation with AWS API Gateway, you can only have a custom domain per one REST API. If you plan on making a large REST API, please make note of this limitation. Also, a fix is in the works and is a top priority.

    In our experience, we manage to have Services with different API and a routing object in our clients.

    To decide if they should be in the same serverless service, you need to get into Modeling. In our case, we answer this questions:

    1. Are the entities related?
    2. Are the entities and methods going to change at the same rate?
    3. Is a consumer going to consume one set of entities without consuming the other?

    When you change games are you going to change players, etc?

    This link can help you with that answer: https://martinfowler.com/articles/microservices.html

提交回复
热议问题