When deploying to Lambda, I think that the library may be deployed together, but when deploying, I could not make a small modification on the console, which was a bit annoying. If I was confused about it, I was advised to use Layers, so a memorandum.
A function that taps the API. The language is Python.
official. https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/configuration-layers.html The library can be imported as a layer and used as a common library. Therefore, there is no need to include the library in the Lambda function. It seems that Layers published by other users can also be used.
The library alone was 4.5MB.
I don't see the inline code and I have to upload it again for a bit of editing.
Select Layers from the menu bar on the left and select "Create Layer"
Upload the name and description, and the zip of the library you want to use, and create it.
At this time, ** Put all the libraries to be used in a folder called "python" and zip the entire python folder. ** ** When uploaded, the library module will be placed directly under / opt. In python, the path is already set in / opt / python, so if you include the library in the python folder and upload it, the path to the library can be used automatically. Refer to the official document for specified folders other than Python. I stumbled on this ...
If you select "Layers" from Lambda Designer, an item to add a layer will appear, so select "Add Layer".
Select "Name", select the layer you created earlier, and add it.
Added to the layer.
Deployment only requires modules and config files, allowing inline code editing!
Not only is the library shared, but it is also convenient for normal deployment. But the trick is, I have to read the official document properly ...
Recommended Posts