getapper / restlessness

A framework to easy develop and deploy serverless lambdas REST APIs
MIT License
7 stars 3 forks source link

Think a strategy about micro-services architecture #88

Closed antoniogiordano closed 4 years ago

antoniogiordano commented 4 years ago

https://www.serverless.com/blog/serverless-workaround-cloudformation-200-resource-limit

https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#share-api-gateway-and-api-resources

antoniogiordano commented 4 years ago

We should add a higher level to the structure, that becomes a collection of services. Every service is a different serverless json config file. During deploy, we can specify the config file, so there should be no specific issue to do that. But deploy function should be moved from a simple CLI command (that is DEPLOY:stage right now) containing the invoke of SLS, to a RLN cli command take internally calls SLS deploy as many times as the different services and json config files created. A couple of things to keep in mind:

  1. RLN Models, Endpoints, Services and Env vars are shared in all the project between all SLS services, we should just decide where every lambda (API o schedule/cron) should be deployed (in terms of SLS service, that is in which SLS functions array we should include it).
  2. Some lambda functions like mongoProxy should be shared between SLS services. We should find the smartest way to do it.
  3. Authentication function should be shared as well, there is a blog explaining some strategies.
androsanta commented 4 years ago

How would we handle dependencies (package.json deps and shared code like models, services)? Regarding point 2: lambda can be invoked also between services (through aws-sdk)

https://github.com/serverless/examples/tree/master/aws-node-shared-gateway here is an example on how to use a shared api gateway

can you link the blog of point 3?

antoniogiordano commented 4 years ago
  1. Every microservice will share the same code and env vars. So we don't really have to do anything about that. It is just a matter of referencing all the single functions in the endpoints folder to the correct LambdaFunction inside the "functions" array in the SLS json.
  2. Yes, we just need to make this easy through the web UI, because after creating a microservice, I will have for example a unique ID from AWS that I will have to use for any further service as a reference for the API gateway. Maybe for the lambdas it's easier since the name can is known before deploying (that is something similar to service + stage + "_" + safeName)
  3. I think it's here somewhere https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#share-api-gateway-and-api-resources