Created
June 29, 2020 11:12
-
-
Save Hironsan/acc3bbf13e5e13b64543de22049b4d79 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
REGION=us-east-1 | |
RUNTIME=python3.7 | |
while getopts :n:r:p: OPT | |
do | |
case $OPT in | |
n) PACKAGE=$OPTARG;; | |
r) REGION=$OPTARG;; | |
p) RUNTIME=$OPTARG;; | |
*) echo "Please specify options correctly." | |
esac | |
done | |
if [ -z "$PACKAGE" ]; then | |
echo "Please specify a package name by -n option." | |
exit 1 | |
fi | |
docker run \ | |
-v $(pwd):/opt \ | |
-it lambci/lambda:build-$RUNTIME \ | |
pip install $PACKAGE -t /opt/python | |
zip -r $PACKAGE.zip python/ | |
aws lambda publish-layer-version \ | |
--layer-name $PACKAGE \ | |
--region $REGION \ | |
--description "$PACKAGE for Lambda Layers" \ | |
--zip-file fileb://$PACKAGE.zip \ | |
--compatible-runtimes $RUNTIME | |
rm -rf python *.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment