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

- **ID:** `aws/lambda-s3-zip-extract-failed`
- **领域:** aws
- **类别:** resource_error
- **错误码:** `InvalidParameterValueException`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

Lambda 部署包的解压后大小（包括层和代码）超过了 250 MB 的限制。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| AWS Lambda API 2015-03-31 | active | — | — |
| AWS SDK for Python 1.27.0 | active | — | — |
| SAM CLI 1.80.0 | active | — | — |

## 解决方案

1. ```
   通过删除未使用的依赖来减少部署包大小。对于 Python，使用虚拟环境，并仅用 'pip install --no-deps' 安装必要的包。然后重新构建并部署。
   ```
2. ```
   使用 AWS Lambda 层将大型库（例如 numpy、pandas）从部署包中分离。创建一个包含该库的层，然后在函数配置中引用它。
   ```
3. ```
   使用 Lambda 容器镜像支持：将函数打包为 Docker 镜像（最大 10 GB），而不是 .zip 文件。示例：'docker build -t myfunction . && aws ecr create-repository --repository-name myfunction && docker push ...'。
   ```

## 无效尝试

- **** — Compressing the deployment package more aggressively (e.g., using maximum compression) doesn't reduce the unzipped size, which is what matters for the limit. (90% 失败率)
- **** — 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. (70% 失败率)
