Home > Mobile >  AWS Layer RequestEntityTooLargeException Terraform
AWS Layer RequestEntityTooLargeException Terraform

Time:11-10

I am trying to deploy a Layer, with the size of 99MB, and I am getting this error.

│ 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" {

This is the .tf

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

  compatible_runtimes = ["python3.8"]
}

The zip is in the right location.

CodePudding user response:

According to the AWS Lambda quotas, you cannot have a deployment package (.zip file archive) with size more than:

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)

There's also a paragraph in the AWS Lambda docs for your 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.

You should try to do one of the following:

  1. Split your current lambda layer into multiple layers
  2. Upload the layer zip to S3, and specify the Object in your terraform lambda config
  • Related