I created a lerna repo where each package is its own serverless service, with its own cloudformation etc. These are separated domains like:
Sometimes one domain will need to know the stack outputs of the other. For example, my cognito authenticated role ( =
auth domain ) has to define that when authenticated it can make execute actions to the API gateway of the
api domain. This introduces many questions.
currently I deploy the domains in a random sequence, but if one requires an output from another, they will need to be deployed in the right sequence; how do you orchestrate this? and what if they reference each other?
how does service A know that it depends on service B? I could use Fn::Include but it would be rather ugly because these dependencies would not be explicitly defined. It would be nicer if you could do something like
require('../service_a').someStackVariableinside service B.
I need this lerna repo structure because otherwise my cloudformation file becomes 1000+ lines. In addition, the setup (plugins) etc. differ for each domain. E.g.
api requires a complicated setup with babel, because it has more business logic that is written in ES6.
Auth on the other hand just sets up some cognito resources and can be deployed much faster without plugins. In short, service separation works really well, but now the challenge is in orchestrating deployment and sharing variables between the services.
Has anyone solved this issue already?