Do not upload unnecessary lambda sources

This commit is contained in:
Mikhail f. Shiryaev 2022-08-10 14:37:06 +02:00
parent 5f3c7524bc
commit 4b2bba2ff1
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -7,18 +7,20 @@ cd "$WORKDIR"
PY_EXEC=python3.9
LAMBDA_NAME=$(basename "$PWD")
LAMBDA_NAME=${LAMBDA_NAME//_/-}
VENV=lambda-venv
rm -rf "$VENV" lambda-package.zip
"$PY_EXEC" -m venv "$VENV"
#virtualenv "$VENV"
# shellcheck disable=SC1091
source "$VENV/bin/activate"
pip install -r requirements.txt
PACKAGE=lambda-package
rm -rf "$PACKAGE" "$PACKAGE".zip
cp -r "$VENV/lib/$PY_EXEC/site-packages" "$PACKAGE"
mkdir "$PACKAGE"
cp app.py "$PACKAGE"
rm -r "$PACKAGE"/{pip,pip-*,setuptools,setuptools-*}
( cd "$PACKAGE" && zip -r ../"$PACKAGE".zip . )
if [ -f requirements.txt ]; then
VENV=lambda-venv
rm -rf "$VENV" lambda-package.zip
"$PY_EXEC" -m venv "$VENV"
# shellcheck disable=SC1091
source "$VENV/bin/activate"
pip install -r requirements.txt
cp -rT "$VENV/lib/$PY_EXEC/site-packages/" "$PACKAGE"
rm -r "$PACKAGE"/{pip,pip-*,setuptools,setuptools-*}
fi
( cd "$PACKAGE" && zip -9 -r ../"$PACKAGE".zip . )
aws lambda update-function-code --function-name "$LAMBDA_NAME" --zip-file fileb://"$PACKAGE".zip