Use Docker to create a zip for layer upload of Python library used by Lambda. The procedure is a sample when requests are zipped.
On the host OS, attach to the version of Python container that uses the library.
$ docker pull python:3.8
$ docker images
$ docker run -itd ImageID bash
$ docker attach ContainerID
On the container side, get the library with pip and zip it.
$ apt-get update & apt-get install zip
$ mkdir python & pip install requests -t ./python
$ zip -r upload.zip python
Exit the container with "Ctrl + p, Ctrl + q", copy the zip from the container to the host, and exit the container.
$ docker cp ContainerID:/root/upload.zip upload.zip
$ docker stop ContainerID
Then upload it.
Recommended Posts