Hey all, I would like to deploy an AWS lambda from...
# aws
p
Hey all, I would like to deploy an AWS lambda from a python file directly, instead of ZIP or docker container, if possible. Therefore, with
Pulumi AI
I implemented the following code, that successfully runs with
pulumi up
. However, in the AWS lambda console, the python file does not actually show up in the Editor. Instead, I get the following error:
Copy code
Runtime.ImportModuleError: Unable to import module 'bid_archiver': No module named 'bid_archiver'
What do I miss?
l
I believe that the AssetArchive should contain a FileArchive (not a file asset), and it should point to the directory containing the source, not to the python file itself.
p
Do you know whether a single python file is possible? I think when I tried it with the FileArchive, I got an error message that it was expecting a zip instead of .py
l
Put the .py file into a subdir, create a FileArchive pointing at that directory, and name the asset "." inside the AssetArchive.
In that example, they don't even put the lambda code into a subdirectory, they just put the current directory in there. Which is slightly wasteful as then you're uploading non-lambda code, but it's just an example, so that's fine. I wouldn't do that normally, especially since you want the lambda zip to change only when the lambda code changes; in that example, the zip will change even when the README.md changes 🙂
BTW AWS requires that the code property point to a zip file. That's not a Pulumi constraint, that's how AWS' API works.
p
Thanks for the detailed answer!
Yes, I understand that AWS requires ZIP or docker, but I thought pulumi may do some magic to convert the directory into a zip file
Ah, given the example I understand that pulumi does generate the zip based on the folder provided
Thanks a lot for the support, @little-cartoon-10569!
It now worked, just need to debug the actual python code now