ERROR REFERENCE
Template exceeds a CloudFormation size or count quota
CloudFormation rejected the template before evaluating a single resource: the body is too large, or a count — resources, parameters, outputs — exceeds its quota. The template is structurally fine; it is just over a hard limit.
WHAT IT MEANS
What this error means
Value at 'templateBody' failed to satisfy constraint: Member must have length less than or equal to 51200— the template body was passed inline, and the inline limit is 51,200 bytes. Via S3, the ceiling is 460,800 bytes.Template format error: Number of resources, ..., is greater than maximum allowed— a count quota (resources cap at 500 per stack).... may not exceed ... bytes— the S3-path size ceiling.
FIX
How to fix it
-
Submit through S3 instead of inline. That alone
raises the body ceiling from 51,200 to 460,800 bytes.
sam deploywith a resolved bucket does this automatically; direct CLI calls should use--template-urlrather than--template-body. - Measure the rendered template — the post-transform output, not your source file. SAM templates expand considerably through the transform.
- Split very large stacks with nested stacks when a count quota is the limit; each nested stack gets its own resource budget.
- Check the quotas page for the specific limit named in the error before restructuring — some quotas are adjustable, most template-shape ones are not.
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor matches the quota wording (medium confidence) and keeps ordinary validation errors with the generic change-set rule. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown
RELATED
Related errors
- InvalidSamDocumentException (schema validation) — the other pre-resource template rejection.
- No changes to deploy — a different way a change set ends before doing anything.