It is convenient to use Layers when putting a library on Lambda

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.

Function to deploy

A function that taps the API. The language is Python.

Lambda Layers feature

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.

If you deploy as it is

The library alone was 4.5MB. image.png

I don't see the inline code and I have to upload it again for a bit of editing. image.png

Use Layers

Select Layers from the menu bar on the left and select "Create Layer" image.png

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 ...

Set to Lambda

If you select "Layers" from Lambda Designer, an item to add a layer will appear, so select "Add Layer". image.png

Select "Name", select the layer you created earlier, and add it. image.png

Added to the layer. image.png

Deployment only requires modules and config files, allowing inline code editing! image.png

Summary

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

It is convenient to use Layers when putting a library on Lambda
It is convenient to use Icecream instead of print when debugging.
It is better to use NTFS when connecting SSD to Linux to create a file server.
Use Heroku in python to notify Slack when a specific word is muttered on Twitter
Let's use AWS Lambda to create a mechanism to notify slack when the value monitored by CloudWatch is exceeded on Python
How easy is it to synthesize a drug on the market?
Is it deprecated to use pip directly?
It is better to use Weight Initializer when initializing with HeNormal with Chainer
[Python] It was very convenient to use a Python class for a ROS program.
It is convenient to use stac_info and exc_info when you want to display traceback in log output by logging.
Creating a Python document generation tool because it is difficult to use sphinx
I tried to use Twitter Scraper on AWS Lambda and it didn't work.
How to use a library that is not originally included in Google App Engine
How to use any or all to check if it is in a dictionary (Hash)
It was a life I wanted to OCR on AWS Lambda to locate the characters.
I realized that it is nonsense to use the module without thinking because it is convenient.
A little trick to know when writing a Twilio application using Python on AWS Lambda
A memorandum on how to use keras.preprocessing.image in Keras
Convenient to use matplotlib subplots in a for statement
[Python] A convenient library that converts kanji to hiragana
Re: Python lambda is useless ^ H ^ H ^ H ^ H ^ H Difficult to use
[Python] What is a tuple? Explains how to use without tuples and how to use it with examples.
How to use GitHub on a multi-person server without a password
How to use Fujifilm X-T3 as a webcam on Ubuntu 20.04
What to do when Japanese is not displayed on matplotlib
[python] A note when trying to use numpy with Cython
When you want to use python2.x on modern Gentoo Linux
[C language] Close () It is dangerous to retry when it fails
Notes on how to use marshmallow in the schema library
A quick explanation from creating AWS Lambda Layers to linking
When you want to hit a UNIX command on Python
VIM is good to use — at least a sneak peek
[Python] What is a slice? An easy-to-understand explanation of how to use it with a concrete example.
How to trick and use a terrible library that is supposed to be kept globally in flask
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
It is good to create an environment with runtime error => venv when using pyplot backends of macosx on a virtual environment created with virtualenv.
How to use Python lambda
The record I was addicted to when putting MeCab on Heroku
A note on what you did to use Flycheck with Python
Data visualization library "folium" by Python is very easy to use
A memorandum when I tried to get it automatically with selenium
When it is troublesome to copy what you built with vue
A note I was addicted to when making a beep on Linux
Things to note when running Python on EC2 from AWS Lambda
How to make a .dylib library from a .a library on OSX (El Capitan)
When I try to use pip, SSL module is not available.
Is R's do.call () a classical higher-order function? Learn how to use
Everything from building a Python environment to running it on Windows
Use AWS lambda to scrape the news and notify LINE of updates on a regular basis [python]