Skip to content

Chalice deployment fails due to large package size #2115

Open

Description

@shekharpalit

Description

My Chalice application is failing to deploy due to the deployment package exceeding the 50MB limit for Lambda functions. The application includes Langchain packages for data processing, which contribute to the large package size.

Current Configuration

My config.json for the Chalice application:

{
  "app_name": "my-app-name",
  "automatic_layer": true,
  "stages": {
    "prod": {
      "api_gateway_stage": "api",
      "environment_variables": {},
      "iam_role_arn": "r",
      "manage_iam_role": false,
      "lambda_memory_size": 3008,
      "lambda_timeout": 900
    },
    "staging": {
      "api_gateway_stage": "api",
      "environment_variables": {},
      "iam_role_arn": "r",
      "log_level": "DEBUG",
      "manage_iam_role": false,
      "lambda_memory_size": 3008,
      "lambda_timeout": 900
    }
  },
  "version": "2.0"
}

Error Message

chalice.deploy.deployer.ChaliceDeploymentError: ERROR - While sending your chalice handler code to Lambda to 
publish_layer_version function "my-fucntion-name-layer", 
received the following error:
 An error occurred (RequestEntityTooLargeException) when calling the 
 PublishLayerVersion operation: Request must be smaller than 70167211 bytes for
  the PublishLayerVersion operation
This is likely because the deployment package is 51.0 MB. Lambda only allows 
deployment packages that are 50.0 MB or less in size. To avoid this error, 
decrease the size of your chalice application by removing code or removing 
dependencies from your chalice application.

Question

How can I create multiple layers for my Lambda function to support deployments larger than 50MB? I'm using Langchain packages for data processing, which are contributing to the large package size.

Additional Information

  • The current deployment package size is 51.0 MB
  • Lambda's size limit is 50.0 MB
  • I'm using Langchain packages for data processing

What I've Tried

  • I've enabled automatic_layer: true in the config, but it doesn't seem to solve the issue

Activity

  1. josiahcoad commented on Oct 31, 2024

    @josiahcoad

    same, same :(

  2. GitToby commented on Jan 6, 2025

    @GitToby

    workaround can include package -> CloudFormation package -> CloudFormation deploy

    chalice package --merge-template=./infra/extras.yaml .pkg/code # ./infra/extras.yaml takes precedence
    aws cloudformation package --template-file=.pkg/code/sam.yaml --s3-bucket=my-bucket > .pkg/cloudformation_final.yaml
    aws cloudformation deploy --template-file=.pkg/cloudformation_final.yaml
    

    This will use the cloudformation package command to upload the lambda source to s3 and deploy that way.

  3. rickgeorges commented on Feb 12, 2025

    @rickgeorges

    I resolved this by modifying my requirements.txt. Freezing Langchain and/or other packages to an earlier version significantly reduced the deployment package size.

  4. adelkedjour commented on Apr 28, 2025

    @adelkedjour

    Same issue, can't even deploy ~18MB that contain only boto3 and chalice?

  5. tareshss commented on Apr 29, 2025

    @tareshss

    You should not need to bundle boto3, its available in the runtime. e.g.

    https://www.feitsui.com/en/article/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions