Skip to content

Instantly share code, notes, and snippets.

@iwootten
Created January 27, 2022 13:49
Show Gist options
  • Save iwootten/1b3d51acabb07770dca024dc33390905 to your computer and use it in GitHub Desktop.
Save iwootten/1b3d51acabb07770dca024dc33390905 to your computer and use it in GitHub Desktop.
Publishes Python Dependencies in a requirements.txt to a AWS Lambda Layer
REGION=eu-west-2
RUNTIME=python3.8
LAYER_NAME=scrapy
docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME \
pip install -r /out/requirements.txt -t /out/build/$LAYER_NAME/python
cd build/$LAYER_NAME
zip -r ../../$LAYER_NAME.zip python/
cd ../..
aws lambda publish-layer-version \
--layer-name $LAYER_NAME \
--region $REGION \
--zip-file fileb://$LAYER_NAME.zip \
--compatible-runtimes $RUNTIME
rm -rf build *.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment