ERROR REFERENCE
Lambda package exceeds a per-function size limit
The function's code artifact is over a hard Lambda limit — the zipped
upload, or the unzipped contents. The deploy fails at
CreateFunction/UpdateFunctionCode, after the
build already succeeded, which is what makes it feel sudden.
WHAT IT MEANS
What this error means
Unzipped size must be smaller than 262144000 bytes— the 250 MB unzipped ceiling, including layers.Request must be smaller than ... bytes(RequestEntityTooLargeException) — the direct-upload zip ceiling.
This is a per-function limit, not the account-wide storage quota —
that one says Code storage limit exceeded and has a
different fix.
FIX
How to fix it
-
Measure the artifact before blaming AWS:
The largest entries are almost always dependencies, not your code.ls -lh .aws-sam/build/*/ unzip -l .aws-sam/build/MyFunction/../artifact.zip | sort -k1 -n | tail -20 - Trim what ships. Move dev/test dependencies out of the runtime requirements, exclude data files the handler never reads, and check for accidentally vendored toolchains.
- Share heavy dependencies through a layer when several functions carry the same libraries — remembering layers still count toward the unzipped total.
- Switch the function to a container image when it is genuinely large: image-based functions get a 10 GB limit.
AUTOMATE THE TRIAGE
Diagnose this automatically
SAM Doctor recognizes both size phrasings (high confidence) and keeps the regional storage quota separate. Runs locally; no AWS access, no log upload.
python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown
RELATED
Related errors
- Code storage limit exceeded — the account-wide quota this limit is often confused with.
- Cannot connect to the Docker daemon — the first hurdle if you take the container-image route.