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

The CloudFormation template is invalid: Template format error: Number of resources, 203, is greater than maximum allowed, 200 #49

Open rkstar007 opened 5 years ago

rkstar007 commented 5 years ago

@dougmoscrop I am using the serverless framework with version 1.32 and below are the change in our serverless.yml files.

service: test-infoapi custom: splitStacks: perFunction: false perType: true envfile: ${file(./config/config-${opt:stage}.yml)}

[root@~]# serverless -v 1.32.0

dougmoscrop commented 5 years ago

You have lots of resources -- either in the root, or in sub-stack, that need to be split up. I suspect it is in the root stack. A resource type that is not being migrated.

KypMon commented 5 years ago

@dougmoscrop Thanks for your amazing plugin! I also met this problem. But when I try to write the stack-map.js, there are errors when I tried to deploy it. TBH, The short example in the readme.MD is a bit of confusing to me. So more example/description/doc would be a great help. Thanks!

delprofundo commented 5 years ago

yes I agree. I can get the plugin to work, it always breaks up the stack the same irrespective of the presence of a stack-map.js.

The docs are not clear on how to make this custom method considering this example:

const stacksMap = require( 'serverless-plugin-split-stacks' ).stacksMap;

stacksMap[ 'AWS::IAM::*' ] = { destination: 'AccessManagement' };
stacksMap[ 'AWS::DynamoDB::*'] = { destination: 'Infrastructure' };
stacksMap[ 'AWS::S3::*'] = { destination: 'Infrastructure' };
stacksMap[ 'AWS::SQS::*'] = { destination: 'Infrastructure' };
stacksMap[ 'AWS::SNS::Topic' ] = { destination: 'Communications' };

1) Is the presence of this information in thefile enough? 2) What does the splitStacks Serverless entry need to include fire this file? I've tried with it there, with it not there. 2) Is the wildcard I have used acceptable?

felipeas commented 5 years ago

A resource type that is not being migrated.

What does determine which resource is being migrated or not?

And yet, i have same questions as @delprofundo.

dougmoscrop commented 5 years ago

By default, resources are migrated based on their type according to: https://github.com/dougmoscrop/serverless-plugin-split-stacks/blob/master/lib/migration-strategy/per-type.js

It is quite conservative.

Wildcards are not supported. You can implement them using a function as described in the readme

The only thing you have to do is create stacks-map.js next to your serverless.yml. The syntax you are showing @delprofundo is sort of legacy. Prefer a module.exports either the mapping object (no wildcards) or a function.

Sorry for the delayed response.

leobarcellos commented 4 years ago

I could manage to get it working using this stacks-map.js below:

const ServerlessPluginSplitStacks = require('serverless-plugin-split-stacks')

ServerlessPluginSplitStacks.resolveMigration = function (resource, logicalId) {
    // console.log("logicalId -->", logicalId, logicalId.indexOf("LogGroup"))
    if (logicalId.indexOf("LogGroup" > -1)) return { destination: "Logs" }
}

In my example I created a "Logs" nested stack and got 186 resources on root instead of 210. Following this strategy you can split it even more if needed, hopefully.

pavinduLakshan commented 4 years ago

@leobarcellos can you give an example of splitting into different stacks.

I tried the following to shift AWS::Lambda::Version to a Version stack, but it didn't work.

const ServerlessPluginSplitStacks = require('serverless-plugin-split-stacks')

ServerlessPluginSplitStacks.resolveMigration = function (resource, logicalId) {
    // console.log("logicalId -->", logicalId, logicalId.indexOf("LogGroup"))
     if (logicalId.indexOf("LogGroup" > -1)) return { destination: "Logs" }
     if (logicalId.indexOf("Version" > -1)) return { destination: "Version" }
}