From a7be0ed5cc264a4c661cca7a8def5d74520c661c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 27 Jul 2024 12:25:31 -0400 Subject: [PATCH] fix: init tf in subdirectory --- modules/common/shell/bash/scripts/terraform-init.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/common/shell/bash/scripts/terraform-init.sh b/modules/common/shell/bash/scripts/terraform-init.sh index 224d461..2fdb159 100755 --- a/modules/common/shell/bash/scripts/terraform-init.sh +++ b/modules/common/shell/bash/scripts/terraform-init.sh @@ -6,14 +6,15 @@ BUCKET_NAME_PART_1="t2" BUCKET_NAME_PART_2="global" BUCKET_NAME_PART_3="terraformstate" -WORKFLOW_FILE=".github/workflows/terraform.yml" +PROJECT_ROOT=$(git rev-parse --show-toplevel) +WORKFLOW_FILE="${PROJECT_ROOT}/.github/workflows/terraform.yml" -if [ ! -f $WORKFLOW_FILE ]; then - WORKFLOW_FILE=".github/workflows/apply.yml" +if [ ! -f "$WORKFLOW_FILE" ]; then + WORKFLOW_FILE="${PROJECT_ROOT}/.github/workflows/apply.yml" fi AWS_ACCOUNT_NUMBER=$( - awk '/aws_account_number: .*/ {print $2}' $WORKFLOW_FILE | # Grab account number + awk '/aws_account_number: .*/ {print $2}' "$WORKFLOW_FILE" | # Grab account number echo "$( read -r s s=${s//\'/} @@ -23,7 +24,7 @@ AWS_ACCOUNT_NUMBER=$( if [ -z "${AWS_ACCOUNT_NUMBER}" ]; then AWS_ACCOUNT_NUMBER=$( - awk '/AWS_ACCOUNT_NUMBER: .*/ {print $2}' $WORKFLOW_FILE | # Grab account number + awk '/AWS_ACCOUNT_NUMBER: .*/ {print $2}' "$WORKFLOW_FILE" | # Grab account number echo "$( read -r s s=${s//\'/}