SAM Doctor

ERROR REFERENCE

Code storage limit exceeded (CodeStorageExceededException)

The account's Lambda code storage quota for the Region is full. It is not about this function's size — every deployed package, every retained version, and every layer in the Region counts toward one budget, and the newest deploy is just the one that hit the wall.

WHAT IT MEANS

What this error means

The default quota is 75 GB per Region. CI pipelines that publish a new version on every deploy and never prune old ones consume it steadily, so this error usually means "months of retained versions", not "one huge function". Deleting the function you were deploying rarely helps; the storage is elsewhere.

FIX

How to fix it

  1. See where the storage went (read-only):
    aws lambda list-functions --query 'Functions[].[FunctionName,CodeSize]' --output table
    aws lambda list-versions-by-function --function-name my-fn --query 'Versions[].[Version,CodeSize]'
  2. Delete unneeded old versions. Keep what aliases point at plus a rollback margin; remove the rest. If versions are published by CI, add pruning to the pipeline so the quota stops refilling.
  3. Remove orphaned layers and functions left behind by deleted stacks and experiments.
  4. Request a quota increase when legitimate usage genuinely needs more than the default - this quota is adjustable through Service Quotas.

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes the quota wording (high confidence) and keeps it distinct from per-function size limits. Runs locally; no AWS access, no log upload.

python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown

RELATED