Good way to organize huge serverless.yml

I want to add, let’s say, 100 functions in severless.yml. Those function are invoked by SNS.

In this case I have to write a list of all subcriptions, which are pairs of topics and functions, in the serverless.yml.

This is apparently very hard to maintain. Is there any good way to organize hundreds of functions in serverless.yml? Or I should have just one function and dispatch events to another functions inside of a lamda?

You can break them up into multiple files of course and read them from those files like:

  foo: ${file(foo.yml)}
  bar: ${file(bar.yml)}

That may help a little. But beyond just make the file itself easier to read trying to maintain the flow of the application itself can get quite complex with SNS. Who subscribes to who and what comes after what can get hard to maintain. You’re basically representing a complex graph as a flat list, like a 2d->1d projection, it can be hard to understand.

One thing that may be worth looking into is the new AWS Step Functions, which there is a Serverless plugin for:

The step functions provide you with a feature that lets you define the relationships between lambdas into, essentially workflow documents. You can visualize these documents as well as rely on it for doing some heavy lifting with regards to parallelism, conditions, error handling and retrying.

Its still a fairly new service but the value outweighs the risk for me and it may be worth looking into for you.


Thanks! This is very helpful!