File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed
tests/workflows/test-plan Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -844,6 +844,28 @@ jobs:
844844 my_var="single"
845845 var_file : tests/workflows/test-plan/test.tfvars
846846
847+ plan_json_tfvars :
848+ runs-on : ubuntu-24.04
849+ name : Plan JSON tfvars
850+ permissions :
851+ contents : read
852+ pull-requests : write
853+ env :
854+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
855+ steps :
856+ - name : Checkout
857+ uses : actions/checkout@v4
858+ with :
859+ persist-credentials : false
860+
861+ - name : Plan
862+ uses : ./terraform-plan
863+ with :
864+ path : tests/workflows/test-plan/vars
865+ variables : |
866+ my_var="single"
867+ var_file : tests/workflows/test-plan/test.tfvars.json
868+
847869 plan_single_sensitive_variable :
848870 runs-on : ubuntu-24.04
849871 name : Plan single sensitive variable
Original file line number Diff line number Diff line change @@ -399,10 +399,16 @@ function create-auto-tfvars() {
399399 fi
400400
401401 local file_name=" ${file_path##*/ } "
402- local name =" ${file_name% .tfvars } "
402+ local extension =" ${file_name##* . } "
403403
404- debug_log " Creating autoloading tfvars file for $file_path : zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER .$name .auto.tfvars"
405- cp " $file_path " " $INPUT_PATH /zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER .$name .auto.tfvars"
404+ if [[ " $extension " == " json" ]]; then
405+ link_name=" zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER .${file_name% .json} .auto.tfvars.json"
406+ else
407+ link_name=" zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER .${file_name% .tfvars} .auto.tfvars"
408+ fi
409+
410+ debug_log " Creating autoloading tfvars file for $file_path : $link_name "
411+ cp " $file_path " " $INPUT_PATH /$link_name "
406412 AUTO_TFVARS_COUNTER=$( printf " %02d\n" " $(( AUTO_TFVARS_COUNTER + 1 )) " )
407413 done
408414 fi
Original file line number Diff line number Diff line change 1+ {
2+ "my_var_from_file" : " monkey" ,
3+ "my_var" : " this should be overridden"
4+ }
You can’t perform that action at this time.
0 commit comments