[For Python] Quickly create an upload file to AWS Lambda Layer

Premise

Use Docker to create a zip for layer upload of Python library used by Lambda. The procedure is a sample when requests are zipped.

procedure

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

[For Python] Quickly create an upload file to AWS Lambda Layer
Create a Layer for AWS Lambda Python with Docker
Posted as an attachment to Slack on AWS Lambda (Python)
[AWS] Try adding Python library to Layer with SAM + Lambda (Python)
Create API with Python, lambda, API Gateway quickly using AWS SAM
[Python Kivy] How to create an exe file with pyinstaller
Create an Excel file with Python3
AWS Layer Creation Script for python
An introduction to Python for non-engineers
File upload to Azure Storage (Python)
I wrote a script to create a Twitter Bot development environment quickly with AWS Lambda + Python 2.7
[Python] Convert CSV file uploaded to S3 to JSON file with AWS Lambda
Create an alias for Route53 to CloudFront with the AWS API
Python vba to create a date string for creating a file name
How to convert Python to an exe file
[Python] Quickly create an API with Flask
Connect to s3 with AWS Lambda Python
An introduction to Python for machine learning
An introduction to Python for C programmers
How to create a JSON file in Python
Play with Lambda layer (python) for about 5 minutes
Create an AWS GPU instance to train StyleNet
[AWS / Lambda] How to load Python external library
Upload files to Google Drive with Lambda (Python)
Summary of studying Python to use AWS Lambda
Create an API server quickly with Python + Falcon
Feel free to turn Python using the library into an AWS Lambda function
Create a setting in terraform to send a message from AWS Lambda Python3.8 to Slack
[Blender x Python] How to create an original object
Create Python version Lambda function (+ Lambda Layer) with Serverless Framework
Create an image file using PIL (Python Imaging Library).
How to set layer on Lambda using AWS SAM
I tried to get an AMI using AWS Lambda
Support for Python 2.7 runtime on AWS Lambda (as of 2020.1)
I want to AWS Lambda with Python on Mac!
Python script to create a JSON file from a CSV file
AWS Lambda python Workaround for "Deployment package is too large to enable inline code editing"
Introduction to Flask Part 1: First try running it locally & create an executable file for distribution
[Python] If you suddenly want to create an inquiry form
Try to operate an Excel file using Python (Pandas / XlsxWriter) ①
Try to operate an Excel file using Python (Pandas / XlsxWriter) ②
How to make a Python package (written for an intern)
[Python] How to output a pandas table to an excel file
How to read an Excel file (.xlsx) with Pandas [Python]
How to create an ISO file (CD image) on Linux
[Python] Allow pip3 packages to be imported on AWS Lambda
About folder structure when uploading Python module to Lambda Layer
Convert Excel file to text in Python for diff purposes
[Python] Scraping in AWS Lambda
Upload a file to Dropbox
An introduction to Python Programming
~ Tips for beginners to Python ③ ~
How to use Python lambda
Introduction to Python For, While
Process the gzip file UNLOADed with Redshift with Python of Lambda, gzip it again and upload it to S3
Create a shell script to run the python file multiple times
Things to note when running Python on EC2 from AWS Lambda
How to create a heatmap with an arbitrary domain in Python
Best practice for logging in JSON format on AWS Lambda / Python
[Python / AWS Lambda layers] I want to reuse only module in AWS Lambda Layers
How to use an external editor for Python development with Grasshopper