AWS 层 RequestEntityTooLargeException Terraform

AWS Layer RequestEntityTooLargeException Terraform

我正在尝试部署一个大小为 99MB 的层,但出现此错误。

│ Error: Error creating lambda layer: RequestEntityTooLargeException:
│   status code: 413, request id: 5a87d055-ba71-47bb-8c60-86d3b00e8dfc
│
│   with aws_lambda_layer_version.aa,
│   on layers.tf line 68, in resource "aws_lambda_layer_version" "aa":
│   68: resource "aws_lambda_layer_version" "aa" {

这是.tf

resource "aws_lambda_layer_version" "aa" {
  filename   = "custom_layers/aa/a.zip"
  layer_name = "aa"

  compatible_runtimes = ["python3.8"]
}

拉链在正确的位置。

根据 AWS Lambda quotas,部署包(.zip 文件存档)的大小不能超过:

50 MB (zipped, for direct upload)

250 MB (unzipped)

This quota applies to all the files you upload, including layers and custom runtimes.

3 MB (console editor)

AWS Lambda 文档中也有一段针对您的 exact error:

General: Error occurs when calling the UpdateFunctionCode Error: An error occurred (RequestEntityTooLargeException) when calling the UpdateFunctionCode operation

When you upload a deployment package or layer archive directly to Lambda, the size of the ZIP file is limited to 50 MB. To upload a larger file, store it in Amazon S3 and use the S3Bucket and S3Key parameters.

您应该尝试执行以下操作之一:

  1. 将您当前的 lambda 层拆分为多个层
  2. 将层 zip 上传到 S3,并在您的 terraform lambda 配置中指定对象