# Cloudformation 500 Resource Limit

**URL:** <https://forum.serverless.com/t/cloudformation-500-resource-limit/20606>\
**Category:** Serverless Framework\
**Tags:** aws, cloudformation\
**Created:** [September 30, 2024, 6:36pm UTC](https://forum.serverless.com/t/cloudformation-500-resource-limit/20606 "2024-09-30T18:36:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kferrone](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kferrone/32/8075_2.png) [@kferrone](https://forum.serverless.com/u/kferrone)\
**Post date:** [September 30, 2024, 6:36pm UTC](https://forum.serverless.com/t/cloudformation-500-resource-limit/20606/1 "2024-09-30T18:36:23Z")

</div>

Customer has one really big serverless file. This is just one out of many repos. This one repo in particular get’s the ‘not more than 500 resources in a cloudformation’ error. I tried a [split stack plugin](https://www.serverless.com/plugins/serverless-plugin-split-stacks) but it doesn’t support v4. Now I’m stuck and don’t really know what to do?

Is there a native v4 way of making nested cfn stacks without having to create yet another serverless file which will create yet another api gateway? I also can’t really tell this customer to “just refactor your app.”

I’m fine with some custom code if needed. I would just need to be pointed to some resource that shows me how to manipulate the underlying CFN.

Edit: Just posting the plugins I found which both seemingly had the same error and does not support v4

> **[Serverless Plugin Split Stacks - Serverless Framework: Plugins](https://www.serverless.com/plugins/serverless-plugin-split-stacks)**
>
> Migrate certain resources to nested stacks

> **[Serverless Nested Stack - Serverless Framework: Plugins](https://www.serverless.com/plugins/serverless-nested-stack)**
>
> A plugin to Workaround for Cloudformation 200 resource limit

This unresolved issue is what I’m stuck on, happens in both of the above:

> <https://github.com/dougmoscrop/serverless-plugin-split-stacks/issues/82>
>
> \`The CloudFormation template is invalid: Template format error: Unresolved resou…rce dependencies \[ServerlessDeploymentBucket\] in the Resources block of the template\`
> 
> I'm getting above error trying to use this plugin but I can't figure out why,
> 
> other plugins:
> \`\`\`
> plugins:
> - serverless-webpack
> - serverless-dynamodb-local
> - serverless-offline
> - serverless-domain-manager
> - serverless-plugin-warmup
> - serverless-es-logs
> - serverless-pseudo-parameters
> - serverless-plugin-split-stacks
> \`\`\`
> 
> split stacks config:
> \`\`\`
> splitStacks:
> perFunction: false
> perType: true
> perGroupFunction: false
> \`\`\`
> and this stacks-map.js:
> \`\`\`
> module.exports = (resourceObj, logicalId) =\> {
> resourceType = resourceObj.Type;
> if (resourceType.startsWith("AWS::ApiGateway::Method")) return { destination: 'AWSApiGatewayMethod', force: true };
> if (resourceType.startsWith("AWS::ApiGateway::Resource")) return { destination: 'AWSApiGatewayResource', force: true };
> if (resourceType.startsWith("AWS::Lambda::Function")) return { destination: 'AWSLambdaFunction', force: true };
> if (resourceType.startsWith("AWS::Lambda::Permission")) return { destination: 'AWSLambdaPermission', force: true };
> if (resourceType.startsWith("AWS::Logs::LogGroup")) return { destination: 'AWSLogsLogGroup', force: true };
> if (resourceType.startsWith("AWS::Logs::SubscriptionFilter")) return { destination: 'AWSLogsSubscriptionFilter', force: true };
> 
> if (resourceType.startsWith("AWS::ApiGateway::Authorizer")) return { destination: 'Misc', force: true };
> if (resourceType.startsWith("AWS::ApiGateway::GatewayResponse")) return { destination: 'Misc', force: true };
> if (resourceType.startsWith("AWS::Events::Rule")) return { destination: 'Misc', force: true };
> if (resourceType.startsWith("AWS::IAM::Role")) return { destination: 'Misc', force: true };
> if (resourceType.startsWith("AWS::S3::Bucket")) return { destination: 'Misc', force: true };
> 
> 
> if (resourceType.startsWith("AWS::ApiGateway::RestApi")) return false;
> if (resourceType.startsWith("AWS::ApiGateway::BasePathMapping")) return false;
> if (resourceType.startsWith("AWS::ApiGateway::Deployment")) return false;
> return false;
> };
> \`\`\`

---

<div class="post-metadata">

**Author:** ![nbcch](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/nbcch/32/7422_2.png) [@nbcch](https://forum.serverless.com/u/nbcch)\
**Post date:** [October 6, 2024, 2:29am UTC](https://forum.serverless.com/t/cloudformation-500-resource-limit/20606/2 "2024-10-06T02:29:01Z")

</div>

A few things you can do:

1. Turn off Lambda versioning by setting `versionFunctions: false` in Serverless.yml
2. Some resources like security groups or IAM roles can be created beforehand and pass into Serverless.yml

Let me know if these work

---

<div class="post-metadata">

**Author:** ![kferrone](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/kferrone/32/8075_2.png) [@kferrone](https://forum.serverless.com/u/kferrone)\
**Post date:** [October 8, 2024, 3:30pm UTC](https://forum.serverless.com/t/cloudformation-500-resource-limit/20606/3 "2024-10-08T15:30:31Z")

</div>

Ultimately, the customer just split the repo into three. This works and I didn’t really have to do anything.
