As we add more features, we finally hit the 200 resources Cloudformation limit so we split it into several services. It happens that we are also turning our code into a monorepo structure, as it allows us to re-use code easily across all functions. So we end up with a monorepo containing several services and found a few challenges:
- Support for several services on the same template
If I’m not mistaken, as it is now we would need to manage each service independently, meaning each of them would be defined in a different serverless.yml, packaged and deployed. Is there a way we can define several services on the same template? This would allow us, for example, to define alarms and other common resources and then reuse them across services. Or defining environment variables and be able to import it on each individual service.
Alternatively to define everything in a single serverless.yml, to import a global serverless.yml common to several services?
Only package and deploy if a service code has changed.
It also becomes quite often that an update only affects one service. So for this use case it becomes quite important to monitor if the code inside a service (or even each individual function) has change so we can ignore it on the packaging and deployment steps. It seems the folks at Seed.run are doing it, but not sure if this feature is available on the Serverless framework.
Split the cloudformation stack
Maybe an alternative to the previous points is to split the deployment of the stack: for example, a reason we hit the 200 resources limit is that we have defined alarms (with its corresponding metrics) for each lambda function, or domain and API Gateway endpoints linked to the lambdas.
I feel it shouldn’t be necessary to deploy these resources at each time we modify an individual lambda function, but even if we can still use
functioncommand to deploy a single lambda, we still need to deploy the whole stack once. Is there any way serverless can split those resources into different cloudformation stacks avoiding the 200 resource limit?
I’m particularly interested in knowing how other users have overcome these challenges, or if there are related improvements coming on the roadmap
Thank you for your help!