Five easy steps to create a custom aws-lambda layer, this step is necessary if you use a mac-os or windows. This because the Lambda Layers which is an Amazon Linux environment.
Resources from https://towardsdatascience.com/how-to-install-python-packages-for-aws-lambda-layer-74e193c76a91
FROM amazonlinux:2.0.20191016.0
RUN yum install -y python37 &&
yum install -y python3-pip &&
yum install -y zip &&
yum clean all
RUN python3.7 -m pip install --upgrade pip &&
python3.7 -m pip install virtualenv
Run the commands below to create your Dockerfile with a tag. usr> docker build -f ".Dockerfile" -t lambdalayer:latest .
usr> docker run -it --name lambdalayer lambdalayer:latest bash
bash> python3.7 -m venv pandas bash> source pandas/bin/activate (pandas) bash> pip install pandas -t ./python (pandas) bash> deactivate
bash> zip -r python.zip ./python/ usr> docker cp lambdalayer:python.zip ./Desktop/
There are a few limitations that you need to be aware of and this includes: You can only use up to 5 layers per Lambda. The size of all your layers unzipped cannot exceed 250mb. Layers are mounted to the /opt directory in the function’s execution environment so be sure to Layer your functions properly if you are going to have more than one.