SAM Doctor

ERROR REFERENCE

Layers consume more than the available size of the function

Attached layers exceed the Lambda function's available size

Lambda adds up the unzipped bytes of the function package and every attached layer version, and rejects the request when the total passes 262,144,000 bytes (250 MB). The check is on the combined total — so attaching one more layer, or a new version of a layer that grew, can fail a function whose own package never changed.

WHAT IT MEANS

What this error means

CREATE_FAILED  AWS::Lambda::Function  ApiFunction
Resource handler returned message: "Layers consume more than the available size of
262144000 bytes (Service: Lambda, Status Code: 400)"

An error occurred (InvalidParameterValueException) when calling the
UpdateFunctionConfiguration operation: Layers consume more than the
available size of the function

The number is a hard Lambda limit for zip-packaged functions, not a quota you can raise. It is measured against unzipped bytes, so the upload sizes you see in the console understate the real total, and the failure often arrives from a layer version that grew rather than from the code you just changed.

SAFE NEXT STEPS

Sum the unzipped bytes, then shed layers

  1. Sum what Lambda actually measures. The limit counts the unzipped bytes of the function package plus every attached layer version, not the zipped upload sizes. Read the attachments without changing anything:
    aws lambda get-function --function-name YOUR_FUNCTION \
      --query "{code:Configuration.CodeSize,layers:Configuration.Layers}"
    The listed CodeSize values are zipped; download and unzip the heaviest layer to count its real bytes.
  2. Drop the layers the function no longer imports. Layers accumulate: a dependency vendored into the package often still rides along as a layer from an earlier design.
  3. Trim the layers that stay. Tests, docs, __pycache__, and unstripped native libraries are usually where the bytes went; publish a slimmer layer version and point the function at it.
  4. Repackage if the dependencies are genuinely that large. Container-image functions get 10 GB, and bulky assets can load from EFS or S3 at runtime instead of shipping in layers.

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes the direct API error and the CloudFormation resource-handler message, in both the 262144000 bytes and the function phrasings, and runs locally without AWS credentials or log upload.

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

RELATED