Skip to content

Instantly share code, notes, and snippets.

@TheFern2
Created August 29, 2023 22:59
Show Gist options
  • Save TheFern2/39bd9876c3e20e77e66e61e28d212379 to your computer and use it in GitHub Desktop.
Save TheFern2/39bd9876c3e20e77e66e61e28d212379 to your computer and use it in GitHub Desktop.
create aws python layer
#!/bin/bash
LAYERS_HOME=~/aws/layers
PACKAGE_NAME="$1"
mkdir -p $LAYERS_HOME/zip/$PACKAGE_NAME $LAYERS_HOME/tmp
python3.11 -m pip install -t $LAYERS_HOME/python_$PACKAGE_NAME $PACKAGE_NAME
current_epoch=$(date '+%s')
# copy package into a python named tmp dir
tmp_dir=$LAYERS_HOME/tmp/$current_epoch/layer_$PACKAGE_NAME/python/
cd_dir=$LAYERS_HOME/tmp/$current_epoch/layer_$PACKAGE_NAME/
mkdir -p $tmp_dir
cp -r $LAYERS_HOME/python_$PACKAGE_NAME/. $tmp_dir
cd $cd_dir
zip -q -r $LAYERS_HOME/zip/$PACKAGE_NAME/python.zip ./*
cd -
#sleep 30
# clean tmp dir
rm -rf $LAYERS_HOME/tmp/
@TheFern2
Copy link
Author

sudo chmod +x create-python-layer.sh
./layer.sh beautifulsoup4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment