Skip to content

LSQL - Chalice deployment failing due to lambda size #161

@tebanieo

Description

@tebanieo

The creation of chalice package is failing due to lambda size limitations.

Steps to reproduce

participant:~/workshop$ ls
LADV  LBED  LCDC  LDC  LDMS  LEDA  LGAM  LGME  LHOL  LMR  LSQL  ddb-replication-role-arn.txt
participant:~/workshop$ python -m venv .venv
participant:~/workshop$ source .venv/bin/activate
(.venv) participant:~/workshop$ cd LSQL
(.venv) participant:~/workshop/LSQL$ ls
(.venv) participant:~/workshop/LSQL$ git clone https://github.com/aws-samples/aws-dynamodb-examples.git
Cloning into 'aws-dynamodb-examples'...
remote: Enumerating objects: 4291, done.
remote: Counting objects: 100% (631/631), done.
remote: Compressing objects: 100% (505/505), done.
remote: Total 4291 (delta 209), reused 223 (delta 117), pack-reused 3660 (from 2)
Receiving objects: 100% (4291/4291), 34.11 MiB | 42.29 MiB/s, done.
Resolving deltas: 100% (2173/2173), done.
(.venv) participant:~/workshop/LSQL$ cd aws-dynamodb-examples/workshops/relational-migration/
(.venv) participant:~/workshop/LSQL/aws-dynamodb-examples/workshops/relational-migration$ ls
README.md   load               mysql_s3.py       setup_tables.sh  test_delete.py  test_query.py  test_sql.py     test_view.py
app.py      migrate.sh         requirements.txt  source-tables    test_desc.py    test_read.py   test_tables.py  test_write.py
chalicelib  mysql_desc_ddb.py  setenv.sh         target-tables    test_get.py     test_scan.py   test_update.py  webapp
(.venv) participant:~/workshop/LSQL/aws-dynamodb-examples/workshops/relational-migration$ pip install chalice mysql-connector-python boto3
...
...
      Successfully uninstalled pip-25.3
Successfully installed blessed-1.25.0 botocore-1.42.28 chalice-1.32.0 click-8.3.1 editor-1.6.6 inquirer-3.4.1 jmespath-1.0.1 mysql-connector-python-9.5.0 pip-25.0.1 python-dateutil-2.9.0.post0 pyyaml-6.0.3 readchar-4.2.1 runs-1.2.2 setuptools-80.9.0 six-1.17.0 urllib3-2.6.3 wcwidth-0.2.14 wheel-0.45.1 xmod-1.8.1

[notice] A new release of pip is available: 25.0.1 -> 25.3
[notice] To update, run: pip install --upgrade pip
(.venv) participant:~/workshop/LSQL/aws-dynamodb-examples/workshops/relational-migration$ source ./setenv.sh
Environment variables set:

MYSQL_HOST = 172.31.26.195
MYSQL_DB = app_db
MYSQL_USERNAME = dbuser
MYSQL_PASSWORD = <PASSWORD HERE!>
MIGRATION_STAGE = relational
MIGRATION_BUCKET = ddb-migrations3bucket-xat4zh8rhzro
SECURITY_GROUP = sg-03e47000d9dd86b43
SUBNET_ID = subnet-025ba1462304337c3

Then when creating the chalice deployment

Chalice configuration file updated with MYSQL_HOST=172.31.26.195
(.venv) participant:~/workshop/LSQL/aws-dynamodb-examples/workshops/relational-migration$ chalice deploy --stage relational
(.venv) participant:~/workshop/LSQL/aws-dynamodb-examples/workshops/relational-migration$ chalice deploy --stage relational
Creating shared layer deployment package.
  Reusing existing shared layer deployment package.
Creating app deployment package.
  Reusing existing app deployment package.
Creating lambda layer: migration-relational-managed-layer
Traceback (most recent call last):
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/awsclient.py", line 359, in publish_layer
    return self._client('lambda').publish_layer_version(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        LayerName=layer_name,
        ^^^^^^^^^^^^^^^^^^^^^
        Content={'ZipFile': zip_contents},
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        CompatibleRuntimes=[runtime],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )['LayerVersionArn']
    ^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/botocore/client.py", line 602, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/botocore/context.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/botocore/client.py", line 1078, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (RequestEntityTooLargeException) when calling the PublishLayerVersion operation: Request must be smaller than 70167211 bytes for the PublishLayerVersion operation

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/deploy/deployer.py", line 376, in deploy
    return self._deploy(config, chalice_stage_name)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/deploy/deployer.py", line 392, in _deploy
    self._executor.execute(plan)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/deploy/executor.py", line 42, in execute
    getattr(self, '_do_%s' % instruction.__class__.__name__.lower(),
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            self._default_handler)(instruction)
            ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/deploy/executor.py", line 55, in _do_apicall
    result = method(**final_kwargs)
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/awsclient.py", line 368, in publish_layer
    raise self._get_lambda_code_deployment_error(e, context)
chalice.awsclient.DeploymentPackageTooLargeError: An error occurred (RequestEntityTooLargeException) when calling the PublishLayerVersion operation: Request must be smaller than 70167211 bytes for the PublishLayerVersion operation

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/cli/__init__.py", line 637, in main
    return cli(obj={})
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/click/core.py", line 1873, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/cli/__init__.py", line 190, in deploy
    deployed_values = d.deploy(config, chalice_stage_name=stage)
  File "/home/participant/workshop/.venv/lib/python3.13/site-packages/chalice/deploy/deployer.py", line 378, in deploy
    raise ChaliceDeploymentError(e)
chalice.deploy.deployer.ChaliceDeploymentError: ERROR - While sending your chalice handler code to Lambda to 
publish_layer_version function "migration-relational-managed-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 50.8 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions