DEV Community

Cover image for Day 22: How to create Python Lambda Layers for external libraries.
Eric Rodríguez
Eric Rodríguez

Posted on • Edited on

Day 22: How to create Python Lambda Layers for external libraries.

The Dependency Problem

Welcome to Day 22. If you try to import requests or import plaid in a standard AWS Lambda function, it will crash. Why? Because Lambda only includes the standard Python library by default.

The Wrong Way

pip install inside your project folder and zipping everything together. This makes your function huge and hard to read in the AWS Console editor.

The Right Way: Lambda Layers

A Layer is a .zip file that sits under your function code. Here is how I built one for my Fintech Agent today:

  1. Folder Structure (Crucial!) AWS is picky. For Python 3.13, you must use this exact structure:

Bash
mkdir -p python/lib/python3.13/site-packages

  1. Install Dependencies Target that specific folder:

Bash
pip install plaid-python requests -t python/lib/python3.13/site-packages

  1. Zip and Upload Zip the python folder (not just the contents!) and upload it to the Layers section in the AWS Console.

Now, simply attach the layer to your function, and import plaid works like magic.

Top comments (0)