CloudFormation Service Limits and Quotas
You'll learn the specific boundaries CloudFormation imposes on template sizes, resource counts, and stack nesting—critical constraints that shape how you architect your infrastructure.
Why Limits Matter
Just like a building has weight limits per floor, AWS CloudFormation has guardrails to ensure stability and performance. Understanding these limits prevents deployment failures and helps you design scalable infrastructure from the start.
Core Service Limits
Template Size Constraints
CloudFormation templates have a maximum size of 51,200 bytes when passed directly, or 1 MB when uploaded to S3. Think of this like a document size limit—if your infrastructure definition grows too large, you'll need to split it or use S3 storage.
Resource Count Limits
Each stack can contain up to 500 resources. If you're defining 501 EC2 instances, databases, or IAM roles in one template, CloudFormation will reject it. This encourages modular design using multiple stacks.
Stack Nesting Constraints
You can nest stacks (stacks that create other stacks) up to 5 levels deep. Imagine Russian nesting dolls—you can only go five dolls deep. This prevents overly complex dependency chains that become hard to manage.
Other Important Quotas
- 200 stacks per region (soft limit, can be increased)
- 200 outputs per stack
- 200 parameters per template
- 200 mappings per template
Working Within Limits
When you hit these boundaries, your options include:
- Breaking large templates into multiple smaller stacks
- Using nested stacks to organize resources hierarchically
- Requesting limit increases through AWS Support for soft limits
- Storing templates in S3 instead of passing them inline
Key Takeaway: CloudFormation enforces specific limits on template size (1 MB via S3), resources per stack (500), and nesting depth (5 levels)—designing within these constraints is essential for successful infrastructure deployments.