File tree Expand file tree Collapse file tree 4 files changed +27
-14
lines changed Expand file tree Collapse file tree 4 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -119,13 +119,6 @@ jobs:
119119 docs/*.md
120120 **/README.md
121121
122- - name : ensure-sha-pinned-actions
123- uses : zgosalvez/github-actions-ensure-sha-pinned-actions@25ed13d0628a1601b4b44048e63cc4328ed03633 # v3
124- with :
125- allowlist : |
126- actions/
127- dflook/
128-
129122 - name : Lint Dockerfile
130123 uses : hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
131124 with :
Original file line number Diff line number Diff line change 33 config :
44 policies :
55 dflook/terraform-apply : ref-pin
6+ actions/* : ref-pin
Original file line number Diff line number Diff line change @@ -436,11 +436,7 @@ function set-plan-args() {
436436 export PLAN_ARGS
437437}
438438
439- function set-remote-plan-args() {
440- set-common-plan-args
441- VARIABLE_ARGS=" "
442- DEPRECATED_VAR_ARGS=" "
443-
439+ function create-auto-tfvars() {
444440 local AUTO_TFVARS_COUNTER=0
445441
446442 if [[ -n " $INPUT_VAR_FILE " ]]; then
@@ -451,9 +447,20 @@ function set-remote-plan-args() {
451447 fi
452448
453449 if [[ -n " $INPUT_VARIABLES " ]]; then
454- echo " $INPUT_VARIABLES " > " $STEP_TMP_DIR /variables.tfvars"
455450 cp " $STEP_TMP_DIR /variables.tfvars" " $INPUT_PATH /zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER .auto.tfvars"
456451 fi
452+ }
453+
454+ function delete-auto-tfvars() {
455+ debug_cmd find " $INPUT_PATH " -regex ' .*/zzzz-dflook-terraform-github-actions-[0-9]+\.auto\.tfvars' -print -delete || true
456+ }
457+
458+ function set-remote-plan-args() {
459+ set-common-plan-args
460+ VARIABLE_ARGS=" "
461+ DEPRECATED_VAR_ARGS=" "
462+
463+ create-auto-tfvars
457464
458465 export PLAN_ARGS
459466}
@@ -585,7 +592,7 @@ function fix_owners() {
585592 fi
586593
587594 if [[ -d " $INPUT_PATH " ]]; then
588- debug_cmd find " $INPUT_PATH " -regex ' .*/zzzz-dflook-terraform-github-actions-[0-9]+\. auto\.tfvars ' -print -delete || true
595+ delete- auto-tfvars
589596 fi
590597
591598 if [[ -f " $HOME /.terraformrc" ]]; then
Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ function apply() {
4141 SAVED_PLAN_VARIABLES=" $VARIABLE_ARGS "
4242 fi
4343
44+ # With OpenTofu >= 1.8.0 Early variable initialization any variables used by the encryption block
45+ # must be available for the apply command, but you can not use the -var or -var-file arguments with a saved plan
46+ # We have to put them in an auto tfvars file as a workaround.
47+
48+ if [[ " $TOOL_PRODUCT_NAME " == " OpenTofu" && -n " $EARLY_VARIABLE_ARGS " ]]; then
49+ create-auto-vars
50+ fi
51+
4452 # shellcheck disable=SC2086
4553 debug_log $TOOL_COMMAND_NAME apply -input=false -no-color -lock-timeout=300s $PARALLEL_ARG $SAVED_PLAN_VARIABLES $PLAN_OUT
4654 # shellcheck disable=SC2086
@@ -51,6 +59,10 @@ function apply() {
5159 APPLY_EXIT=${PIPESTATUS[0]}
5260 >&2 cat " $STEP_TMP_DIR /terraform_apply.stderr"
5361
62+ if [[ " $TOOL_PRODUCT_NAME " == " OpenTofu" && -n " $EARLY_VARIABLE_ARGS " ]]; then
63+ delete-auto-vars
64+ fi
65+
5466 else
5567 # There is no plan file to apply, since the remote backend can't produce them.
5668 # Instead we need to do an auto approved apply using the arguments we would normally use for the plan
You can’t perform that action at this time.
0 commit comments