How to deploy dependencies using python?

How can I deploy dependencies using python?
I want to have a lambda function connect to postgres, so i need psycopg2. I dont have any idea on how to zip this together with my code

Brett Francis had the same issue, and ended up constructing the zip file himself (through a script iā€™m assuming). You can see part of the chat thread here: https://gitter.im/serverless/serverless?at=57c680d02dcc4f3129484f87

Hi @polvoazul. I have never needed to prezip my python functions as per the gitter conversation.

pip install your packages beside the function code:

$ pip install -t project/root/dir/ <package-name>

Then import in code as you would usually:

import json
import boto3
import psycopg2

def your_handler(event, context):
...
1 Like