Packages installed in the layer are different that the ones from aws_lambda_powertools[all]
#1807
-
Hi! 👋 Below is the list of installed packaged I get with a lambda using the import pkg_resources
def lambda_handler(event, context):
print(*sorted(f"{i.key}=={i.version}" for i in pkg_resources.working_set), sep="\n") Output: aws-lambda-powertools==2.5.0
aws-xray-sdk==2.11.0
awslambdaric==2.0.4
boto3==1.20.32
botocore==1.23.32
fastjsonschema==2.16.2
jmespath==0.10.0
pip==22.0.4
pydantic==1.10.2
python-dateutil==2.8.2
s3transfer==0.5.2
setuptools==58.1.0
simplejson==3.17.2
six==1.16.0
typing-extensions==4.4.0
urllib3==1.26.9
wrapt==1.14.1 And these are the packages I get by installing ❯ python3.9 -m venv venv
❯ . venv/bin/activate
❯ pip install 'aws_lambda_powertools[all,aws-sdk]==2.5.0'
❯ pip freeze --local
aws-lambda-powertools==2.5.0
aws-xray-sdk==2.11.0
boto3==1.26.42
botocore==1.29.42
fastjsonschema==2.16.2
jmespath==1.0.1
pydantic==1.10.4
python-dateutil==2.8.2
s3transfer==0.6.0
six==1.16.0
typing_extensions==4.4.0
urllib3==1.26.13
wrapt==1.14.1 Here's the difference (removed pip and setuptools from the left, which is the list from the layer): Questions:
I'm assuming it's a good practice to add (Side question: Any plans on updating the boto3 version in next releases of the layer and the package?) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey @ericbn, thanks for another great question ;) TL;DR: This is because we remove what's already available in Lambda when building the Layer, whereas locally you'll be bringing that as a peer dependency because of AWS X-Ray SDK. Answering the questions now:
Not in the context you ran with
You can try this by downloading the actual Layer we build for Lambda, which will already have no In the Lambda Layer however, we do the following as part of the build process:
Could you send us this question from your corporate email? Lambda team is aware is outdated and not ideal, so we'd like to do a +1 on your behalf to help prioritize it.
The ideal scenario would be Lambda Runtime to have more regular updates. As it's outside of our control, we have two options here: A. Improve our messaging (I somehow thought we did) in the Local development section that the AWS SDK available at Lambda Runtime may not be up to date. Therefore, customers should bundle AWS SDK into their dependencies (Layer won't) if they need it. B. Potentially lock I think we should do A regardless. As for B, I think it can be fragile as we won't know when it might break - instead I'd like us to keep asking Lambda to prioritize more regular updates so this becomes less of an issue for everyone. Please let us know!! Thank you, |
Beta Was this translation helpful? Give feedback.
Hey @ericbn, thanks for another great question ;)
TL;DR: This is because we remove what's already available in Lambda when building the Layer, whereas locally you'll be bringing that as a peer dependency because of AWS X-Ray SDK.
Answering the questions now:
Not in the context you ran with
pkg_resources
, because (A) it brings additional libraries likeawslambdaric
only available at runtime, (B) we're setting a minimumboto3
version to match with what's available at Lambda runtime at the time of writing (quite old), (C) and X-Ray SDK depends on boto3 1.11.3 or higher sopip/poetry/hat…