top of page
Programming

How to add a Python library as an AWS layer

A guide on adding a Python library as an AWS layer.


Not all libraries are present in the environment provided by AWS lambda (Obviously! It’s not possible). AWS provides a way to tackle this problem. If you want to use a common library (present in pip or a custom library) across various lambda functions, layers are the way to do it.

As of today, lambda does not provide requests . It is a commonly used library in python. I will take this as an example and create a layer for it in AWS.

  1. Create a folder named python

pip install requests -t .

The above command will install the Python packages and their dependencies in the current folder, which is python .

The contents of the folder look like this to me:

2. Zip the folder

3. Open the layers tab in AWS and click on the button Create Layer .


4. Under name enter the desired name. Click on upload a zip file and upload the file you had zipped earlier. Select the appropriate runtimes and you are done.

Congrats!!! Your AWS layer is ready to be used with lambda functions.


This blog was originally published in the personal blog website of Gourav : https://gourav-dhar.com
0 comments

Related Articles

Categories

Let's Get
Social

  • alt.text.label.Twitter
  • alt.text.label.LinkedIn
  • 25231
Subscribe to our NewsLetter

Join our mailing list to get a notification whenever a new blog is published. Don't worry we will not spam you.

bottom of page