Skip to content

Instantly share code, notes, and snippets.

@ryantuck
Created March 17, 2016 19:01
Show Gist options
  • Select an option

  • Save ryantuck/839739339438e131de4a to your computer and use it in GitHub Desktop.

Select an option

Save ryantuck/839739339438e131de4a to your computer and use it in GitHub Desktop.
notes on aws lambda

aws lambda

some stuff to know about deploying a function to aws lambda:

function itself

main.py should look like this:

function handler_fn(event, context):
    # do stuff
    return { 'some': 'response'}

packaging

all external packages need to live at same directory as main.py.

easy way to do this is make a virtualenv, install everything, then move the site-packages directory:

virtualenv test-env
source test-env/bin/activate
pip install requests gspread arrow
cp -r test-env/lib/python2.7/site-packages/* deploy-pkg/
cp main.py deploy-pkg/
cd deploy-pkg
zip -r ../lambda-pkg.zip *

once you have your .zip, upload it to s3 and hit the console.

etc

  • pandas is hard to package up
  • might want to set a timeout longer than 3 seconds for long-running functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment