Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/test-plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,28 @@ jobs:
my_var="single"
var_file: tests/workflows/test-plan/test.tfvars

plan_json_tfvars:
runs-on: ubuntu-24.04
name: Plan JSON tfvars
permissions:
contents: read
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Plan
uses: ./terraform-plan
with:
path: tests/workflows/test-plan/vars
variables: |
my_var="single"
var_file: tests/workflows/test-plan/test.tfvars.json

plan_single_sensitive_variable:
runs-on: ubuntu-24.04
name: Plan single sensitive variable
Expand Down
12 changes: 9 additions & 3 deletions image/actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,16 @@ function create-auto-tfvars() {
fi

local file_name="${file_path##*/}"
local name="${file_name%.tfvars}"
local extension="${file_name##*.}"

debug_log "Creating autoloading tfvars file for $file_path: zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER.$name.auto.tfvars"
cp "$file_path" "$INPUT_PATH/zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER.$name.auto.tfvars"
if [[ "$extension" == "json" ]]; then
link_name="zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER.${file_name%.json}.auto.tfvars.json"
else
link_name="zzzz-dflook-terraform-github-actions-$AUTO_TFVARS_COUNTER.${file_name%.tfvars}.auto.tfvars"
fi

debug_log "Creating autoloading tfvars file for $file_path: $link_name"
cp "$file_path" "$INPUT_PATH/$link_name"
AUTO_TFVARS_COUNTER=$(printf "%02d\n" "$((AUTO_TFVARS_COUNTER + 1))")
done
fi
Expand Down
4 changes: 4 additions & 0 deletions tests/workflows/test-plan/test.tfvars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"my_var_from_file": "monkey",
"my_var": "this should be overridden"
}
Loading