Deploy workflow_approve_rerun_lambda as zip package

This commit is contained in:
Mikhail f. Shiryaev 2022-07-28 14:23:59 +02:00
parent 0db9dda5f3
commit 2338d01a20
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4
5 changed files with 20 additions and 22 deletions

3
tests/ci/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*_lambda/lambda-venv
*_lambda/lambda-package
*_lambda/lambda-package.zip

View File

@ -1,2 +0,0 @@
lambda-venv
lambda-package.zip

View File

@ -1,15 +1,24 @@
#!/usr/bin/env bash
set -xeo pipefail
WORKDIR=$(dirname "$0")
cd "$WORKDIR"
PY_EXEC=python3.9
LAMBDA_NAME=$(basename "$PWD")
LAMBDA_NAME=${LAMBDA_NAME//_/-}
VENV=lambda-venv
py_exec=$(which python3)
py_version=$(basename "$(readlink -f "$py_exec")")
rm -rf "$VENV" lambda-package.zip
virtualenv "$VENV"
"$PY_EXEC" -m venv "$VENV"
#virtualenv "$VENV"
# shellcheck disable=SC1091
source "$VENV/bin/activate"
pip install -r requirements.txt
PACKAGES="$VENV/lib/$py_version/site-packages"
cp app.py "$PACKAGES/"
( cd "$PACKAGES" && zip -r ../../../../lambda-package.zip . )
PACKAGE=lambda-package
rm -rf "$PACKAGE" "$PACKAGE".zip
cp -r "$VENV/lib/$PY_EXEC/site-packages" "$PACKAGE"
cp app.py "$PACKAGE"
rm -r "$PACKAGE"/{pip,pip-*,setuptools,setuptools-*}
( cd "$PACKAGE" && zip -r ../"$PACKAGE".zip . )
aws lambda update-function-code --function-name team-keys-lambda --zip-file fileb://lambda-package.zip
aws lambda update-function-code --function-name "$LAMBDA_NAME" --zip-file fileb://"$PACKAGE".zip

View File

@ -1,13 +0,0 @@
FROM public.ecr.aws/lambda/python:3.9
# Install the function's dependencies using file requirements.txt
# from your project folder.
COPY requirements.txt .
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.handler" ]

View File

@ -0,0 +1 @@
../team_keys_lambda/build_and_deploy_archive.sh