aws
deployment_error
ai_generated
true
An error occurred (InvalidParameterValueException): Unzipped size must be smaller than 262144000 bytes
ID: aws/lambda-package-too-large
88%Fix Rate
90%Confidence
100Evidence
2019-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Lambda deployment package exceeds the 250MB unzipped limit (or 50MB zipped for direct upload). Common when bundling large dependencies like NumPy, pandas, PyTorch, or native compiled libraries.
genericWorkarounds
-
85% success Use Lambda Layers to separate large dependencies
# Create a layer with large dependencies: mkdir -p python/lib/python3.11/site-packages pip install pandas numpy -t python/lib/python3.11/site-packages/ zip -r layer.zip python/ aws lambda publish-layer-version --layer-name my-deps --zip-file fileb://layer.zip # Attach layer to function (up to 5 layers, 250MB total unzipped)
Sources: https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html
-
92% success Use container image packaging instead of zip (up to 10GB)
# Dockerfile: FROM public.ecr.aws/lambda/python:3.11 COPY requirements.txt . RUN pip install -r requirements.txt COPY app.py . CMD ["app.handler"] # Build and push to ECR, then create Lambda from image
Sources: https://docs.aws.amazon.com/lambda/latest/dg/images-create.html
-
78% success Strip unnecessary files from dependencies to reduce size
# Remove tests, docs, __pycache__, .dist-info: find python/ -type d -name '__pycache__' -exec rm -rf {} + find python/ -type d -name 'tests' -exec rm -rf {} + find python/ -name '*.pyc' -delete # For numpy/scipy: strip debug symbols from .so files: find python/ -name '*.so' -exec strip {} +
Dead Ends
Common approaches that don't work:
-
Compressing the zip file more aggressively
90% fail
AWS checks the unzipped size, not the zipped size. Better compression reduces upload time but doesn't affect the unzipped limit.
-
Splitting code into multiple Lambda functions
70% fail
If the large dependencies are shared across all functions, each function still needs the same large package. Splitting code doesn't reduce dependency size.
Error Chain
Frequently confused with: