https://pantsbuild.org/ logo
#general
Title
# general
a

average-breakfast-91545

03/04/2023, 1:48 PM
Hey friends. I'm trying to use pants to bundle a lambda function as a pex binary, following the advice in this issue about the retirement of
lambdex
. I've uploaded the pex to lambda, and the handler is invoked correctly, but it's unable to resolve
boto3
, which should be present by default in the lambda runtime. My guess is that pants' sys path magic is preventing it from resolving. Any clues?
1
Disregard that - fixed by inheriting the path. Thanks for 🦆
👍 1
e

enough-analyst-54434

03/04/2023, 2:22 PM
Did you do that with a build time option or by setting
PEX_INHERIT_PATH=x
in the lambda environment?
a

average-breakfast-91545

03/04/2023, 2:23 PM
The former
e

enough-analyst-54434

03/04/2023, 2:30 PM
Ok, you can do the latter as well in case you weren't aware - say you generally want hermeticity in your PEX but only want to let the env leak in in very particular use cases. All the knobs like this are here: https://pex.readthedocs.io/en/v2.1.125/api/vars.html or
pex --help-variables
a

average-breakfast-91545

03/04/2023, 2:31 PM
Thanks! I'll do some reading, I'm interested in the implications of PEX_ROOT. atm I get a warning that the directory is non-writeable
e

enough-analyst-54434

03/04/2023, 2:37 PM
On AWS Lambda you want
PEX_ROOT=/tmp
👍 1
That's the only portion of the fs that can be written IIRC.
a

average-breakfast-91545

03/04/2023, 2:38 PM
Yes, that's correct
e

enough-analyst-54434

03/04/2023, 2:38 PM
You can also set that one at build time with
--runtime-pex-root
.
12 Views