DEV Community

Mohan Sharma
Mohan Sharma

Posted on • Edited on

How to create Lambda Layer in Python

Use Lambda layers to package code and dependencies that you want to reuse across multiple functions. Layers usually contain library dependencies, a custom runtime, or configuration files.

Below are the steps to create lambda layer and test it with lambda function.

  • mkdir lambda_layer
  • mkdir -p python
  • pip install requests -t ./python --python-version 3.14 --only-binary=:all:
  • Zip python directory.
  • Go to AWS and create Lambda layer by uploading python.zip file.
  • Create lambda function with the same runtime version eg. 3.13 and attach lambda layer to it. Lambda Layer
  • import module required modules in lambda_function.py handle file Sample lambda function code
  • Test the function by creating test event.

Test Lambda Response

Top comments (0)