Create AWS Lambda Layers for python using Zappa

(0 comments)

Here are quick steps to create Lambda Layer of python packages. (click below "read more" to read full article):

  1. create empty folder and create two files in it. 
    1. zappa_settings.py
    2. requirements.txt
  2. requirements.txt will have python packages for which you want to create layers.
  3. in zappa_settings.py, it needs to have folllowing content:
    • {
        "layer": {
          }
      }
  4. Follow below steps in sequence:
    • Create virtual env with python version which you are going to use in layers.
      • python -m venv env
      • source env/bin/activate
      • pip install -r requirements.txt
      • zappa package layer -o "python.zip"
      • unzip python.zip -d ./python
      • rm -r python.zip
      • zip -r python.zip python
    • if you are using AWS CLI and don't want to create and upload layer manually, use following command:
      • aws lambda publish-layer-version --layer-name "some-layer" --zip-file fileb://python.zip
      • Note down Layer ARN, That you can use it in lambda function. 
Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required