Skip to content

Instantly share code, notes, and snippets.

@Hironsan
Created June 29, 2020 11:12
Show Gist options
  • Save Hironsan/acc3bbf13e5e13b64543de22049b4d79 to your computer and use it in GitHub Desktop.
Save Hironsan/acc3bbf13e5e13b64543de22049b4d79 to your computer and use it in GitHub Desktop.
#!/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