Created
June 17, 2018 09:34
-
-
Save shereshevsky/1cce806fcfdba35228cefdf2f99e1d17 to your computer and use it in GitHub Desktop.
Prepare Python code for AWS Lambda function deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LAMBDA_HANDLER_FILE="main.py" | |
| BUCKET="test-lambda-functions" | |
| UUID=$(uuidgen) | |
| PACKAGE_NAME="$UUID.zip" | |
| ENV_NAME="$UUID" | |
| virtualenv -p python3.6 /tmp/$ENV_NAME | |
| . /tmp/$ENV_NAME/bin/activate | |
| pip install -r requirments.txt | |
| deactivate | |
| cp $LAMBDA_HANDLER_FILE /tmp/$ENV_NAME/lib/python3.6/site-packages/ | |
| cd /tmp/$ENV_NAME/lib/python3.6/site-packages/ && zip -r /tmp/$PACKAGE_NAME ./* && cd - | |
| aws s3 cp /tmp/$PACKAGE_NAME s3://$BUCKET/$PACKAGE_NAME | |
| rm /tmp/$PACKAGE_NAME | |
| rm -rf /tmp/$ENV_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment