Skip to content

Instantly share code, notes, and snippets.

@tswann
Last active December 5, 2019 23:05
Show Gist options
  • Save tswann/3c4c53aabf90fbf821121040d541a0cf to your computer and use it in GitHub Desktop.
Save tswann/3c4c53aabf90fbf821121040d541a0cf to your computer and use it in GitHub Desktop.
# !!!!!!!!!!!!!!!!!!!!!!
# Leaving this for reference, but I tested and it doesn't work in this case.
# The package requires native dependencies and thus a virtual env - can't just package up the deps on their own
# and as we know site-packages within the VENV is > 250MB when unzipped, so even if you put it S3 it doesn't matter.
# Back to the drawing board! TS
# Create a new S3 bucket to contain the lambda package (I just did this manually in the UI)
# locally, package up the dependencies (excluding *their* dependencies - i.e. only what is in requirements.txt)
cd api/
pip install -r requirements.txt --no-deps -t output
zip -r python.zip output/ predict.py
# Check zip file size at this point, it should be in the region of 50 - 60MB
# Add package to the S3 bucket created earlier (replace 'tom-limits-test' with your own bucket name!)
aws s3 cp ./python.zip s3://tom-limits-test
# Update your lambda function to use the package stored in S3 (again, replace function-name and s3-bucket with your own names)
aws lambda update-function-code --function-name test_fund_axis --s3-bucket tom-limits-test --s3-key python.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment