Skip to content

Commit

Permalink
Don't set auto approve flag when applying saved remote plans
Browse files Browse the repository at this point in the history
It makes terraform hang. Terraform doesn't ask for approval anyway.
  • Loading branch information
dflook committed Feb 9, 2024
1 parent cbf7e5e commit ee97dcc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions image/entrypoints/apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setup
init-backend-workspace
set-plan-args

AUTO_APPROVE="-auto-approve"
PLAN_OUT="$STEP_TMP_DIR/plan.out"

function update_comment() {
Expand All @@ -29,10 +30,17 @@ function apply() {

set +e
if [[ -n "$PLAN_OUT" ]]; then

if [[ "$TERRAFORM_BACKEND_TYPE" == "cloud" ]]; then
# Using the auto approve flag when applying a saved remote plan makes terraform hang
# It does not prompt for approval anyway
AUTO_APPROVE=""
fi

# shellcheck disable=SC2086
debug_log $TOOL_COMMAND_NAME apply -input=false -no-color -auto-approve -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT
debug_log $TOOL_COMMAND_NAME apply -input=false -no-color $AUTO_APPROVE -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT
# shellcheck disable=SC2086
(cd "$INPUT_PATH" && $TOOL_COMMAND_NAME apply -input=false -no-color -auto-approve -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT) \
(cd "$INPUT_PATH" && $TOOL_COMMAND_NAME apply -input=false -no-color $AUTO_APPROVE -lock-timeout=300s $PARALLEL_ARG $PLAN_OUT) \
2>"$STEP_TMP_DIR/terraform_apply.stderr" \
| $TFMASK
APPLY_EXIT=${PIPESTATUS[0]}
Expand Down

0 comments on commit ee97dcc

Please sign in to comment.