Skip to content

Instantly share code, notes, and snippets.

@yogeshlonkar
Last active February 10, 2020 18:18
Show Gist options
  • Save yogeshlonkar/b6135f02e43130dabeaeb14c31366350 to your computer and use it in GitHub Desktop.
Save yogeshlonkar/b6135f02e43130dabeaeb14c31366350 to your computer and use it in GitHub Desktop.
AWS Golang monorepo lambdas build.sh
#!/usr/bin/env bash
source ./functions.sh
# iterate over each package in array, create function and zip it
for func in "${function_dirs[@]}"
do
lambda_func=${func}-function
echo "Generating ${lambda_func} artifact"
# since each lambda directory contains exactly same main.go
# below command will generate new function feach lambda
GOARCH=amd64 GOOS=linux go build -o ${lambda_func} ./${func}/main.go
zip ${lambda_func} ${lambda_func}
rm ${lambda_func} # remove binary
done
#!/usr/bin/env bash
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# adds all lambda package/directory
function_dirs=($(ls -1 ${BASE_DIR} | grep "\-lambda"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment