-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from umccr/update-build-script
Update build script
- Loading branch information
Showing
5 changed files
with
32 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ node_modules/ | |
|
||
# Environment files | ||
*.log | ||
/lambdas/layers/python/ | ||
/cdk.out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
install: | ||
pip install -r requirements.txt # pulls in CDKv2 `aws-cdk-lib` and `construct` libs | ||
npm install -g aws-cdk | ||
|
||
brew tap aws/tap | ||
brew reinstall aws-sam-cli | ||
build: | ||
sam-beta-cdk build | ||
# Build lambda Layer | ||
for dir in $(shell find ./lambdas/layers -maxdepth 1 -mindepth 1 -type d -exec basename {} \;); do ./lambdas/layers/create_layer_package.sh $$dir; done | ||
# Build Cdk to cdk.out | ||
cdk synth | ||
deploy: build | ||
cdk deploy -a .aws-sam/build --profile ${AWS_PROFILE} | ||
cdk deploy UmccrEventBus | ||
cdk deploy UmccrEventBusSchemaStack | ||
run: | ||
sam-beta-cdk local invoke | ||
sam local invoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
#!/bin/bash | ||
|
||
LAYER_NAME=$1 | ||
SCRIPT_DIR=$(dirname $0) | ||
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" | ||
|
||
if test -z "$LAYER_NAME"; then | ||
echo "LAYER_NAME is not set! Specify the layer for which to create the Lambda package." | ||
exit 1 | ||
fi | ||
|
||
# spcifiy the lib directory (according to AWS Lambda guidelines) | ||
export PKG_DIR="python" | ||
export PKG_DIR=$SCRIPT_DIR/"python" | ||
export LAYER_DIR=$SCRIPT_DIR/${LAYER_NAME} | ||
|
||
# clean up any existing files | ||
rm ${LAYER_NAME}.zip | ||
rm -rf ${PKG_DIR} | ||
cp -R ${LAYER_NAME}/ ${PKG_DIR}/ | ||
rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR} | ||
cp -R ${LAYER_DIR}/ ${PKG_DIR}/ | ||
|
||
# install the python libraries (without dependencies) | ||
docker run --rm -v $(pwd)/${PKG_DIR}:/foo -w /foo lambci/lambda:build-python3.8 pip install -r requirements.txt --no-deps -t ./ | ||
docker run \ | ||
--platform=linux/x86-64 \ | ||
--rm \ | ||
-v ${SCRIPT_PATH}/python:/foo \ | ||
-w /foo \ | ||
public.ecr.aws/sam/build-python3.8 \ | ||
pip install -r requirements.txt --no-deps -t ./ | ||
|
||
# clean the lib directory | ||
rm -rf ${PKG_DIR}/*.dist-info | ||
find python -type d -name __pycache__ -exec rm -rf {} + | ||
|
||
# create the package zip | ||
zip -r ${LAYER_NAME}.zip ./${PKG_DIR}/ | ||
zip -r ${LAYER_DIR}.zip ${PKG_DIR}/ | ||
|
||
# remove the inflated directory | ||
rm -rf ${PKG_DIR}/ |
Empty file.