SAM Doctor

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

FIX

How to fix it

  1. Submit through S3 instead of inline. That alone raises the body ceiling from 51,200 to 460,800 bytes. sam deploy with a resolved bucket does this automatically; direct CLI calls should use --template-url rather than --template-body.
  2. Measure the rendered template — the post-transform output, not your source file. SAM templates expand considerably through the transform.
  3. Split very large stacks with nested stacks when a count quota is the limit; each nested stack gets its own resource budget.
  4. 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