If my dependencies for the python_awslambda backen...
# general
q
If my dependencies for the python_awslambda backend exceed the 50MB size limit allowed by lambda, what is the recommendation here? can i split up the dependencies into multiple
lambda.zip
files, then upload each zip as a separate lambda layer?
b
One option would be to instead build a docker image and use a docker-backed lambda. AFAIK, there's not an easy way to use the lambda backend to create a layer of dependencies, but you can at least tell it to only package your code and not the dependencies: https://www.pantsbuild.org/docs/reference-python_awslambda#codeinclude_requirementscode I don't know of the best way to get pants to build layers, but I could imagine stringing together along the lines of how https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/ builds a PEX file with only dependencies and then exports that to a venv... you'd have split up the dependencies between multiple PEXes/venvs to get multiple layers, though.
q
Got it thanks! I was looking at layers to see if i can do avoid building docker images as to minimize the build/deploy time, as well as the cold start
b
cc'ing @bitter-ability-32190 who wrote that post, to see if he's got additional thoughts
b
I'm not familiar with lambdas. I think in the end you'll just have to weigh tradeoffs. I can tell you the linked blog post minimizes cold start (installs a venv as part of the docker build. And does everything as multi stage to leverage docker layer caches and parallelization