|
1 | 1 | # # This script is run before the Terraform apply command. |
2 | 2 | # # It ensures all Node.js dependencies are installed, generates any required dependencies, |
3 | 3 | # # and builds all Lambda functions in the workspace before Terraform provisions infrastructure. |
| 4 | +# pre.sh runs in the same shell as terraform.sh, not in a subshell |
| 5 | +# any variables set or changed, any change of directory will persist once this script exits and returns control to terraform.sh |
| 6 | +# REGION=$1 |
| 7 | +# ENVIRONMENT=$2 |
| 8 | +# ACTION=$3 |
4 | 9 |
|
5 | | -# npm ci |
| 10 | +# # Helper function for error handling |
| 11 | +# run_or_fail() { |
| 12 | +# "$@" |
| 13 | +# if [ $? -ne 0 ]; then |
| 14 | +# echo "$* failed!" >&2 |
| 15 | +# exit 1 |
| 16 | +# fi |
| 17 | +# } |
6 | 18 |
|
7 | | -# npm run generate-dependencies --workspaces --if-present |
| 19 | +# echo "Running app pre.sh" |
| 20 | +# echo "REGION=$REGION" |
| 21 | +# echo "ENVIRONMENT=$ENVIRONMENT" |
| 22 | +# echo "ACTION=$ACTION" |
8 | 23 |
|
9 | | -# npm run lambda-build --workspaces --if-present |
| 24 | +## Required logic for building and pushing Lambda container images to ECR before Terraform provisions infrastructure. |
| 25 | +# GIT_TAG="$(git describe --tags --exact-match 2>/dev/null || true)" |
| 26 | +# if [ -n "${GIT_TAG}" ]; then |
| 27 | +# RELEASE_VERSION="${GIT_TAG#v}" |
| 28 | +# export TF_VAR_container_image_tag_suffix="release-${RELEASE_VERSION}-$(git rev-parse --short HEAD)" |
| 29 | +# echo "On tag: $GIT_TAG, image tag suffixes will be: release-${RELEASE_VERSION}-$(git rev-parse --short HEAD)" |
| 30 | +# else |
| 31 | +# export TF_VAR_container_image_tag_suffix="sha-$(git rev-parse --short HEAD)" |
| 32 | +# echo "Not on a tag, image tag suffix will be: sha-$(git rev-parse --short HEAD)" |
| 33 | +# fi |
| 34 | + |
| 35 | +# # change to monorepo root |
| 36 | +# cd $(git rev-parse --show-toplevel) |
| 37 | + |
| 38 | +# run_or_fail npm ci |
| 39 | +# run_or_fail npm run generate-dependencies --workspaces --if-present |
| 40 | +# run_or_fail npm run lambda-build --workspaces --if-present |
| 41 | + |
| 42 | +# # revert back to original directory |
| 43 | +# cd - |
0 commit comments