Create AWS Lambda Layer [Python]
Similar to Python environments, AWS Lambda Layers provide a way to handle external libraries and dependencies for your serverless functions.
Think of a Layer as a zip archive containing libraries. These archives are uploaded to AWS and referenced by your Lambda functions. When a function is invoked, they are accessible just like locally installed packages.
Get Raymond Toh’s stories in your inbox
Join Medium for free to get updates from this writer.
If you are new to Lambda Function, you can visit my Step-by-step guide on [Free Project] AWS Lambda with API Gateway
Create Lambda Layer [Step-by-Step]
- Check your environment runtime version.
2. Go to Google Colab Here. Run the following command in Colab. Remember to update your Runtime from Step 1.
import os
RUNTIME = "python3.10" #UPDATE TO YOUR RUNTIME in Step 1
DIR_PATH = f"python/lib/{RUNTIME}/site-packages"
os.makedirs(DIR_PATH)3. Verify the folders are created by clicking Refresh Button.
4. Run the below command. Remember to update the package.
PACKAGE = "pandas" #UPDATE THE PACKAGE HERE
!python3 -m pip install --upgrade {PACKAGE} -t {DIR_PATH}5. Verify the packages have been installed in the site-packages folder.
6. Run the below command.
!zip -r {PACKAGE}.zip python7. Verify that your package has been zipped.
8. Right Click your package and Download it.
9. In AWS Lambda, Click on Layer, and Create Layer.
10. Upload the zip file. Choose the runtime you used in Step 1. Follow the default setting and Create Layer.
11. Congratulation! You have successfully created a Lambda Layer!
Use Lambda Layer [Step-by-Step]
- Go to your Lambda Function. Click on Layers under your Lambda Function.
2. Click on Add a Layer.
3. Choose Custom Layers. Pick the Layer you created. The version should be 1. Then Click on Add.
4. Verify the layer have been added.
Congratulation! You have added a layer to your function! Do take note that a layer can be reused on other Lambda Functions.
I’ll be sharing articles about the applications I’m creating while exploring free AWS services. Join me to stay updated on my journey!
Past Articles:
AWS Free Tier Zero Budget Setup
[Free Project] AWS Lambda with API Gateway


![[Free Project] AWS Lambda with API Gateway](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*PwbP57-uHyHN1t4RUyP68w.png)








