How to deploy a large application to Lambda using Serverless, bypassing or not reacking CloudFormation resource limit

amazon-cloudformationamazon-lambdaamazon-web-servicesdeployment

I am using Serverless(https://github.com/serverless/serverless) to deploy my functions to AWS Lambda. However, Now I started getting the error:

Template format error: Number of resources, 217, is greater than maximum allowed, 200

After some research I found out that this limit is the limit from AWS CloudFormation, soI was wondering how I can deploy my application to Lambda via Serverless.

Any help would be appriciated.

Thanks!

Best Answer

The 200 number is a hard limit. You will not be able to deploy this application, as is, through serverless.

However, if you're willing to break things up, you can get around it. CloudFormation has that 200-resource limit for a reason, and straight up CloudFormation users have been wrestling with it for a while. There are three ways we have been handling this:

  1. Reduce the number of resources you're using (not always possible).
  2. Use nested templates, where a parent template invokes other templates.
  3. Break up your template into more than one template running in parallel.

The 'serverless' framework likely doesn't have a native way to split things up, so you will have to do some work. Probably by splitting your template into two different templates, as I doubt it will do nested.