How to create a python lambda layer

Nic Wanavit
Published in
2 min readMay 17, 2021

If you have been using AWS Lambda, one of the nicest feature is that you can check, test and edit code directly from console. However, this is limited to 3 MB of package size, once you install pretty much any packages, it will exceed that quota.

AWS Lambda layer is used instead of installing many libraries for use in AWS Lambda functions. This gives you 250 MB headroom to install libraries.

This is easier that you think,


docker, bash

  1. create a requirement file
|- requirements.txt

2. download the build script

for convenience, I have published the build script in here, you can select build with deps or without deps

wget ''

3. run the script


This will create a file called for you to upload to aws console or use with sam.

4. upload the package

aws lambda publish-layer-version --layer-name 'test' --region 'us-east-1' --zip-file

5. set the permission

aws lambda add-layer-version-permission
--layer-name <your layer name>
--version-number 1
--statement-id <any string you want>
--principal '*' # this is public permission
--action lambda:GetLayerVersion
--region <us-east-1>

6. add it to your lambda function

you can add using sam, cli, or console

I have created a project template using sam, nbdev, and github action here