Skip to content

Commit 4a6c5b3

Browse files
committed
Copy early variables into auto tfvars for apply command
1 parent ba20984 commit 4a6c5b3

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.github/zizmor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ rules:
33
config:
44
policies:
55
dflook/terraform-apply: ref-pin
6+
dflook/terraform-plan: ref-pin
67
actions/*: ref-pin

image/entrypoints/apply.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exec 3>&1
2929
function apply() {
3030
local APPLY_EXIT
3131

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

3535
# With Terrraform >= 1.10 Ephemeral variables must be specified again in the apply command.
@@ -46,9 +46,10 @@ function apply() {
4646
# We have to put them in an auto tfvars file as a workaround.
4747

4848
if [[ "$TOOL_PRODUCT_NAME" == "OpenTofu" && -n "$EARLY_VARIABLE_ARGS" ]]; then
49-
create-auto-vars
49+
create-auto-tfvars
5050
fi
5151

52+
set +e
5253
# shellcheck disable=SC2086
5354
debug_log $TOOL_COMMAND_NAME apply -input=false -no-color -lock-timeout=300s $PARALLEL_ARG $SAVED_PLAN_VARIABLES $PLAN_OUT
5455
# shellcheck disable=SC2086
@@ -58,15 +59,17 @@ function apply() {
5859
| tee "$STEP_TMP_DIR/terraform_apply.stdout"
5960
APPLY_EXIT=${PIPESTATUS[0]}
6061
>&2 cat "$STEP_TMP_DIR/terraform_apply.stderr"
62+
set -e
6163

6264
if [[ "$TOOL_PRODUCT_NAME" == "OpenTofu" && -n "$EARLY_VARIABLE_ARGS" ]]; then
63-
delete-auto-vars
65+
delete-auto-tfvars
6466
fi
6567

6668
else
6769
# There is no plan file to apply, since the remote backend can't produce them.
6870
# Instead we need to do an auto approved apply using the arguments we would normally use for the plan
6971

72+
set +e
7073
# shellcheck disable=SC2086,SC2016
7174
debug_log $TOOL_COMMAND_NAME apply -input=false -no-color -auto-approve -lock-timeout=300s $PARALLEL_ARG $PLAN_ARGS "$(masked-deprecated-vars)" $VARIABLE_ARGS
7275
# shellcheck disable=SC2086
@@ -76,9 +79,9 @@ function apply() {
7679
| tee "$STEP_TMP_DIR/terraform_apply.stdout"
7780
APPLY_EXIT=${PIPESTATUS[0]}
7881
>&2 cat "$STEP_TMP_DIR/terraform_apply.stderr"
82+
set -e
7983

8084
fi
81-
set -e
8285

8386
if [[ "$TERRAFORM_BACKEND_TYPE" == "cloud" || "$TERRAFORM_BACKEND_TYPE" == "remote" ]]; then
8487
if remote-run-id "$STEP_TMP_DIR/terraform_apply.stdout" "$STEP_TMP_DIR/terraform_apply.stderr" >"$STEP_TMP_DIR/remote-run-id.stdout" 2>"$STEP_TMP_DIR/remote-run-id.stderr"; then

tests/workflows/test-early-eval/s3/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ terraform {
4444
}
4545
}
4646

47-
required_version = "1.8.8"
47+
required_version = "1.9.0"
4848
}

0 commit comments

Comments
 (0)