4

I have recently started using serverless, I completed the tutorial on serverless-stack.com and I wanted to see if there was a way could represent the domain model in an application. I've searched for some samples but I can't seem to find anything.

I have an application that I would like to model. How would I reference this in the main serverless.yml file? How would I make them part of the same API gateway?

/users
serverless.yml
/posts
serverless.yml
/comments
serverless.yml

thanks in advance

Jimi
  • 1,867
  • 7
  • 31
  • 55
  • It is three different API Gateways as Trent writes. But you have the option of stitching them together with API Gateway Custom Domain and have path prefix for each. So example.com/users/* points to the Users API Gateway microservice. example.com/posts/* points to the Posts API Gateway. I think that is a nice way of combining microservices. I have each microservice register at the custom domain on deploy with cloudformation. – doorstuck Jul 13 '17 at 05:42

2 Answers2

1
  • You're correct from a DDD and MSA perspective that Users, Posts and Comments are different micro services and thus should have their own serverless.yml. This implies one API Gateway for each. That's a good thing.
  • It's probably a lot easier if they were in separate repos as well, for ease of CI/CD. You don't want a single commit to trigger deployment of 3 services.
  • If you really do want a single API that aggregates Users, Posts and Comments, then perhaps a fourth API that acts as a facade to the other three would be best. It's an established design pattern in OO, SOA and MSA.
Trent Bartlem
  • 2,213
  • 1
  • 13
  • 22
0

I have developed a package in npm to generate a serverless base project using

  • typeScript
  • hexagonal architecture (DDD)
  • Initial example.

https://www.npmjs.com/package/amc-serverless-generate