Hi all. I'd like to understand how to package my l...
# python
Hi all. I'd like to understand how to package my lambda functions (written in python) from pulumi (also using python). Am I expected to create a pulumi.Archive of my whole project, then pass that to aws.lambda.Function() ? Right now we build the zip manually, I'd like to switch to a cleaner way if that's an option
So what I've done previously is to have a folder with the handler code in it and then in the root have a bash script that does the
pip install
and then pulumi up. Then in the pulumi code for the function have something like
code=pulumi.AssetArchive({".": pulumi.FileArchive("app")})
Pulumi will then zip everything up for you and push it up
so something like:
Copy code
myfunction = aws.lambda_.Function(
    code=pulumi.AssetArchive({".": pulumi.FileArchive("app")}),
And then the bash script is something like:
Copy code

pushd ./app

pip3 install -r requirements.txt -t .


pulumi up
so I just need to run the bash script to install the requirements and run pulumi up
A lot of text, but hopefully that helps
🙌 2
So, thanks to your help I now have something I'm not to unhappy with - I wrapped the pip installing of dependencies into a custom (dynamic) pulumi resource/provider, that gets called before the lambda. It's still a bit shaky (in particular, Asset/File archives can't take an Output in apparently, which is a bit messy), but I'll probably share my code once it's a bit cleaner