dougmoscrop / serverless-plugin-split-stacks

A plugin to generate nested stacks to get around CloudFormation resource/parameter/output limits
297 stars 68 forks source link

Template format error: Parameter count 61 is greater than max allowed 60. #123

Open mharini opened 4 years ago

mharini commented 4 years ago

Hi,

My split stack configuration is as below:

splitStacks: perGroupFunction: true nestedStackCount: 20

I also have versionFunctions: false

I am getting the error: Template format error: Parameter count 61 is greater than max allowed 60.

What configuration should I change to fix this issues? Please help!

dougmoscrop commented 4 years ago

Sorry at this point you have to audit your cloudformation-update template to see which one has the most params.. you could write a very very small .js script to do this for you (also I'd love a PR that outputs this information!)

mharini commented 4 years ago

In serverless.yml, There are 61 functions defined. That is the source of this.

Can you please elaborate more on the .js script you've mentioned?

dougmoscrop commented 4 years ago

just something like:

const template = require('./serverless/cloudformation-update.json') Object.entries(template.Resources).forEach(resource => // some debug logic

mharini commented 4 years ago

Okay.. So now, the functions defined in serverless.yml is the reason behind this. Is there any solution or workaround to solve this issue?

morficus commented 4 years ago

this issue seems to be the same as #91

morficus commented 4 years ago

@mharini are you use AppSync by any chance?

dougmoscrop commented 4 years ago

Patching to support parameter count as a hint to start a new stack should not be difficult. I might have time tonight to look at it.

mharini commented 4 years ago

@morficus No. I am not using AppSync.

vicary commented 4 years ago

So while we wait for @dougmoscrop, one of my teammates came up with a somewhat working snippet.

// lib/utils.js#stackHasRoom

  stachHasRoom(stack) {
    const resources = stack.Resources || {};
    const outputs = stack.Outputs || {};
    const referenceCount = Object.values(resources).reduce(
      (prev, resource) => prev + this.getReferencedResources(resource).length, 
      0
    );

    return Object.keys(resources) < 200
      && Object.keys(outputs) < 60
      && referenceCount < 60;
  }

Not sure if resource references are the only things get parameterized though. If this sounds like a right direction, maybe we can start a PR?

morficus commented 4 years ago

@dougmoscrop ping - any chance we could get this patched in a v1.10?

morficus commented 3 years ago

Trying to ping @dougmoscrop once more, to see if the above solution is acceptable and if he would be interested in a PR

dougmoscrop commented 3 years ago

If you can PR this and it has tests and works I will happily release it!

vicary commented 3 years ago

@dougmoscrop hey thanks for the reply. I can make a PR but really needs your input since I'm not super familiar with the way CloudFormation works.

My snippet above will resulting in some of the nested stacks containing only 20 resources because of the high parameter count, if this sounds like an authentic limitation of the SAM model syntax I'll start a PR.

dougmoscrop commented 3 years ago

Yeah, exactly - not even SAM, it's just plain CloudFormation limits.

morficus commented 3 years ago

Fun fact: AWS has raised the template parameter limit from 60 to 200!

https://aws.amazon.com/about-aws/whats-new/2020/10/aws-cloudformation-now-supports-increased-limits-on-five-service-quotas/