Skip to content

Commit ee97dcc

Browse files
committed
Don't set auto approve flag when applying saved remote plans
It makes terraform hang. Terraform doesn't ask for approval anyway.
1 parent cbf7e5e commit ee97dcc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

image/entrypoints/apply.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ setup
88
init-backend-workspace
99
set-plan-args
1010

11+
AUTO_APPROVE="-auto-approve"
1112
PLAN_OUT="$STEP_TMP_DIR/plan.out"
1213

1314
function update_comment() {
@@ -29,10 +30,17 @@ function apply() {
2930

3031
set +e
3132
if [[ -n "$PLAN_OUT" ]]; then
33+
34+
if [[ "$TERRAFORM_BACKEND_TYPE" == "cloud" ]]; then
35+
# Using the auto approve flag when applying a saved remote plan makes terraform hang
36+
# It does not prompt for approval anyway
37+
AUTO_APPROVE=""
38+
fi
39+
3240
# shellcheck disable=SC2086
33-
debug_log $TOOL_COMMAND_NAME apply -input=false -no-color -auto-approve -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT
41+
debug_log $TOOL_COMMAND_NAME apply -input=false -no-color $AUTO_APPROVE -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT
3442
# shellcheck disable=SC2086
35-
(cd "$INPUT_PATH" && $TOOL_COMMAND_NAME apply -input=false -no-color -auto-approve -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT) \
43+
(cd "$INPUT_PATH" && $TOOL_COMMAND_NAME apply -input=false -no-color $AUTO_APPROVE -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT) \
3644
2>"$STEP_TMP_DIR/terraform_apply.stderr" \
3745
| $TFMASK
3846
APPLY_EXIT=${PIPESTATUS[0]}

0 commit comments

Comments
 (0)