broad-processor-92400
11/22/2022, 6:11 AMlambdex_handler.handler
? That is, a universal entrypoint that runs whatever is configured in a BUILD
file.
Previously, with python_awslambda
, we set handler="path/to/whatever.py:handler"
which both defines the 'root' of the packaging and also the handler function, and then our CDK construct for a pants lambda just needs to be told about the zip file and we're good to go (the construct can just set handler: 'lambdex_handler.handler'
because that always works).
With PEX, it seems like we'll have to set entry_point="path/to/whatever.py:handler"
(or just the file) to define the packaging, and then duplicate that into the CDK construct by also specifying path.to.whatever:handler
. This is annoying to write twice, and risks inconsistencies.broad-processor-92400
11/22/2022, 6:11 AMPEX-INFO
from the zip file but that's... not so nice!
For example, a __pex__.something.configured_entry_point
magic path would allow us to set handler: '__pex__.something:configured_entry_point'
happy-kitchen-89482
11/22/2022, 1:20 PMbroad-processor-92400
11/22/2022, 2:57 PMenough-analyst-54434
11/22/2022, 3:05 PM__pex__
Pex also finally got support for closing over environments. Both were needed to free itself from API consumers to allow cleanly cutting over to Pex 3.x.
The closing over environments thing would mean lambdex can change to shipping as just another distribution that was a main-delegator ~like uvicorn. So lambdex then just has a fixed lamdex_handler:handle but where that delegates to can be controlled from env vars. On the Pants side we'd just use Pex's ~new:
--inject-env INJECT_ENV
Environment variables to freeze in to the application environment. (default: [])
To freeze in your handler from the BUILD file target metadata as-is today.enough-analyst-54434
11/22/2022, 3:06 PMenough-analyst-54434
11/22/2022, 3:09 PMbroad-processor-92400
11/22/2022, 8:51 PM