Python package as Layer in AWS Lambda

Python package as Layer in AWS Lambda

When it comes to python every where we talk about the libraries , for the aws lambda(serverless) by default aws is providing the numpy and other packages

Making the custom packages

# Use case1:

Like when i want to use the requests or mysql ..etc module to communicate with my REST api's which not default provided by aws

whenever we import this libraries

import requests

Module is not found error

Steps to create lambda layer:

step1: Open your terminal and create a folder give a proper name (lambda_pymysql_layer..)

step2: change directory to lambda_pymysql_layer then create folder name it should be python

mkdir lambda_pymysql_layer
cd lambda_pymysql_layer
mkdir python

stpe3:

pip3 install pymysql -t ./ (install your package in the current directory)

step4: Then zip your folders

step5: Zip the folder from python directory

step6: import this zip in add files of lambda function

step7: import pymysql