Created
July 3, 2016 04:00
-
-
Save mikeblum/260e843986c84c9c9c0c2f1bea82188a to your computer and use it in GitHub Desktop.
Revisions
-
mikeblum created this gist
Jul 3, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #!/bin/bash # expects the lambda function .py file to be in the same directory as this script. # based off of Amazon's official documentation: # http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-deployment-pkg.html#with-s3-example-deployment-pkg-python # get the lambda function lambda_func_file=$1 lambda_func="${lambda_func_file%.*}" # exit if no file specified [[ -z "$1" ]] && { echo "Lambda function is empty" ; exit 1; } # generate a deployment timestamp timestamp=$(date +%Y-%m-%d-%H:%M:%S) # create a deployments directory if one doesn't already exist mkdir -p ${PWD}/deployments zip_file="lambda-func-$lambda_func-$timestamp.zip" zip_path=${PWD}/deployments/$zip_file # ignore folder path to site-packages but preserve the structure inside of site-packages pushd $VIRTUAL_ENV/lib/python2.7/site-packages/ zip -r9 $zip_path . popd pushd $VIRTUAL_ENV/lib64/python2.7/site-packages/ zip -r9 $zip_path . popd # add Python code zip -9 $zip_path $lambda_func_file # echo back the deployment ZIP for further processing echo 'deployment ZIP: ' $zip_path # deploy to AWS Lambda aws lambda update-function-code --function-name $lambda_func --zip-file fileb://$zip_path --publish