There was no article that only pinpointed what I wanted to do, so I created it as a memo
It's almost the same as the method of the article Common library with AWS Lambda Layers, but ** pip install
without including any self-made source. If you want to reuse only the module on lambda ** I couldn't find it even if I searched for the method, so I made an article.
(Because I want to use it many times!)
$ mkdir python
#If you have any other modules you want, put them all in your python directory
$ pip install module_name -t ./python
#Layer the contents of the python directory.Compress to zip
$ zip -r layer.zip python/
Make the S3 bucket first
Omitted as it is easy to upload in the AWS console of the GUI
When the file size is large or the communication line is poor (!), It will fail unless uploaded via the command line.
Install aws-cli v2 and execute the following command on it.
#Check backet name
$ aws s3 ls
2019-05-07 19:04:54 xxxxxxxxxxxxx # <=Bucket name
#Upload to s3
#aws s3 cp File name you want to upload Bucket name
$ aws s3 cp ./layer.zip s3://xxxxxxxxxxxxx
Wait (˘ω˘)
For 3 and 4, Add Layer to Lambda Function in the article introduced in Overview earlier. A2% E6% 95% B0% E3% 81% ABlayer% E3% 82% 92% E8% BF% BD% E5% 8A% A0% E3% 81% 99% E3% 82% 8B) I was fine.
(Sorry for the miscellaneous. Thank you very much to @t_okkan for creating the article!)
Recommended Posts