Package size difference when using pip vs lambda layer #1237
|
When I install the library via pip the package size for version 1.26.0 is only 1.6MB but when I use the layer, it seems to be a lot bigger (causing my lambda function to go over the 250 MB limit). My function code is only about 11 MB. Is this expected? |
Replies: 2 comments
|
You existing lambda project probably includes some of the common dependencies like $ python3 -m venv .venv
$ source .venv/bin/activate
$ pip3 install aws-lambda-powertools
$ du -sh .venv
96M .venvWhere as the lambda layer for powertools is always adds So you have some options here:
In the future some of this will be also resolved by an issue for boto3 to reduce it's size (boto/botocore#2365) and there is a powertools issue to remove boto from the lambda layer. (see #1164) |
|
Closing as we documented in v2 that all dependencies are optional and Lambda Layers are optimized to get to 2MB with all deps. https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer |
Closing as we documented in v2 that all dependencies are optional and Lambda Layers are optimized to get to 2MB with all deps.
https://docs.powertools.aws.dev/lambda/python/latest/#lambda-layer