Skip to content

Commit 65e9999

Browse files
vulkoingimroboquat
authored andcommitted
Add a lock timeout for plan/apply and general timeout on apply
1 parent f7f90a0 commit 65e9999

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

dev/preview/workflow/lib/terraform.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
77
# shellcheck source=./common.sh
88
source "${SCRIPT_PATH}/common.sh"
99

10+
TF_CLI_ARGS_plan=${TF_CLI_ARGS_plan:-""}
11+
TF_CLI_ARGS_apply=${TF_CLI_ARGS_apply:-""}
12+
13+
export TF_CLI_ARGS_plan="${TF_CLI_ARGS_plan} -lock-timeout=5m"
14+
export TF_CLI_ARGS_apply="${TF_CLI_ARGS_apply} -lock-timeout=5m"
15+
1016
if [ -n "${DESTROY-}" ]; then
11-
if [ -n "${TF_CLI_ARGS_plan-}" ] && ! grep -q "destroy" <<<"${TF_CLI_ARGS_plan}"; then
12-
TF_CLI_ARGS_plan="${TF_CLI_ARGS_plan} -destroy"
13-
else
14-
export TF_CLI_ARGS_plan="-destroy"
15-
fi
17+
export TF_CLI_ARGS_plan="${TF_CLI_ARGS_plan} -destroy"
1618
fi
1719

1820
function check_workspace() {
@@ -117,7 +119,7 @@ function terraform_apply() {
117119
check_workspace "${WORKSPACE}"
118120
fi
119121

120-
terraform apply "${plan_location}"
122+
timeout --signal=INT --foreground 10m terraform apply "${plan_location}"
121123

122124
popd || return "${ERROR_CHANGE_DIR}"
123125
}

0 commit comments

Comments
 (0)