InvalidParameterValueException aws config_error ai_generated true

发生错误 (InvalidParameterValueException):调用 UpdateFunctionCode 操作时:解压后的大小必须小于 262144000 字节

An error occurred (InvalidParameterValueException) when calling the UpdateFunctionCode operation: Unzipped size must be smaller than 262144000 bytes

ID: aws/lambda-unzipped-size-exceeded-error

其他格式: JSON · Markdown 中文 · English
85%修复率
90%置信度
1证据数
2023-03-10首次发现

版本兼容性

版本状态引入弃用备注
Lambda API 2015-03-31 active
AWS CLI 2.15.0 active

根因分析

Lambda 函数部署包超过 250 MB 的解压大小限制(262,144,000 字节),通常是由于大型依赖项或捆绑的层。

English

The Lambda function deployment package exceeds the 250 MB unzipped size limit (262,144,000 bytes), often due to large dependencies or bundled layers.

generic

官方文档

https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html

解决方案

  1. Move large dependencies to Lambda layers. Create a layer with the heavy libraries and attach it to the function. Example: `aws lambda publish-layer-version --layer-name my-layer --zip-file fileb://layer.zip` then `aws lambda update-function-configuration --function-name my-function --layers arn:aws:lambda:us-east-1:123456789012:layer:my-layer:1`
  2. Use AWS Lambda with container images (up to 10 GB) instead of zip deployment. Build a Docker image with the function code and dependencies, push to ECR, and update the function to use the image.

无效尝试

常见但无效的做法:

  1. Compressing the deployment package with a higher compression ratio (e.g., zip -9) to reduce the zip file size. 95% 失败

    The limit is on unzipped size, not the zip file size; compression does not reduce unzipped content.

  2. Removing unnecessary files from the deployment package but keeping large dependencies intact. 70% 失败

    The bulk of the unzipped size often comes from dependencies; cosmetic cleanup may not reduce size enough.