InvalidParameterValueException
aws
resource_error
ai_generated
true
调用 CreateFunction 操作时发生错误 (InvalidParameterValueException):解压后的大小必须小于 262144000 字节
An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: Unzipped size must be smaller than 262144000 bytes
ID: aws/lambda-s3-zip-extract-failed
82%修复率
88%置信度
1证据数
2023-08-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| AWS Lambda API 2015-03-31 | active | — | — | — |
| AWS SDK for Python 1.27.0 | active | — | — | — |
| SAM CLI 1.80.0 | active | — | — | — |
根因分析
Lambda 部署包的解压后大小(包括层和代码)超过了 250 MB 的限制。
English
The Lambda deployment package's unzipped size exceeds the 250 MB unzipped limit, including layers and code.
官方文档
https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html解决方案
-
通过删除未使用的依赖来减少部署包大小。对于 Python,使用虚拟环境,并仅用 'pip install --no-deps' 安装必要的包。然后重新构建并部署。
-
使用 AWS Lambda 层将大型库(例如 numpy、pandas)从部署包中分离。创建一个包含该库的层,然后在函数配置中引用它。
-
使用 Lambda 容器镜像支持:将函数打包为 Docker 镜像(最大 10 GB),而不是 .zip 文件。示例:'docker build -t myfunction . && aws ecr create-repository --repository-name myfunction && docker push ...'。
无效尝试
常见但无效的做法:
-
90% 失败
Compressing the deployment package more aggressively (e.g., using maximum compression) doesn't reduce the unzipped size, which is what matters for the limit.
-
70% 失败
Deleting unnecessary files from the package but still including large libraries (e.g., full Python packages) often fails because the unzipped size remains above 250 MB.