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 put them in the same api gateway?
相关问题
- How to block HTTP and allows only HTTPS for AWS AP
- Reference an Authorizer definition in an API Gatew
- API Gateway Websockets - Dealing with 10 minute id
- How to define variables in a DRY way
- Sending raw Body JSON to AWS Lambda via API gatewa
相关文章
- AWS API Gateway caching ignores query parameters
- URI-based Versioning for AWS API Gateway
- Export existing AWS Lambda and API Gateway to Clou
- AWS API Gateway and Lambda to return image
- How can I find the arn of an api gateway stage?
- AWS Lambda Container destroy event
- Difference between SAM template and Cloudformation
- Create methods under / using CF for API Gateway
In your example you would want to keep them in the same serverless framework. I would create two files
player.js
andgame.js
insrc/controllers
to seperate out the logic.You can setup serverless with the following YAML file
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:
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:
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
A serverless framework projects deploys a single API Gateway. So if you want it to be in different API Gateways you need separate serverless framework projects.
Depending on the size of the services you are making it can make sense or it might not.
To merge the two API Gateways higher up you can use API Gateway Custom Domains and proxy the requests based on the path to different API Gateways and stages, keeping one single domain for them all.