terraform-github-actions icon indicating copy to clipboard operation
terraform-github-actions copied to clipboard

v2 potentially breaks using .json as input for tfvars

Open bjacoby-rn opened this issue 7 months ago • 3 comments

Problem description

Hello,

We've been using .json tfvars inputs with your actions and have no issues on any version of v1.

It looks like:

{
  "image_tag": {
    "dev": "bxx34sx-9x1x0"
  }
}

We do this because it's easier for our pipeline to edit json than tfvars.

We tried v2 today and got the following error:

Error: Argument or block definition required

  on zzzz-dflook-terraform-github-actions-00.uat-params.json.auto.tfvars line 1:
   1: {

An argument or block definition is required here.

Not sure if this was explained in the release notes or something, but we don't use the deprecated "var" option.

Terraform version

1.0.5

Backend

s3

Workflow YAML

- name: terraform plan
        id: terraform-plan
        uses: dflook/terraform-plan@v1
        with:
          path: "terraform/${{ inputs.app }}"
          label: "${{ inputs.app }} on ${{ inputs.environment }}"
          add_github_comment: "changes-only"
          var_file: |
            ${{ steps.set-vars.outputs.var-files }}
          backend_config_file: ${{ steps.set-vars.outputs.backend }}
          variables: |
            env = "${{ steps.set-vars.outputs.env }}"
            region = "${{ steps.set-vars.outputs.region }}"

Workflow log

Initializing provider plugins...
  - Reusing previous version of hashicorp/null from the dependency lock file
  - Reusing previous version of hashicorp/aws from the dependency lock file
  - Reusing previous version of hashicorp/local from the dependency lock file
  - Installing hashicorp/null v3.2.2...
  - Installed hashicorp/null v3.2.2 (signed by HashiCorp)
  - Installing hashicorp/aws v5.50.0...
  - Installed hashicorp/aws v5.50.0 (signed by HashiCorp)
  - Installing hashicorp/local v2.5.1...
  - Installed hashicorp/local v2.5.1 (signed by HashiCorp)
  Terraform has made some changes to the provider dependency selections recorded
  in the .terraform.lock.hcl file. Review those changes and commit them to your
  version control system if they represent changes you intended to make.
  
  Terraform has been successfully initialized!

Error: Argument or block definition required

  on zzzz-dflook-terraform-github-actions-00.uat-params.json.auto.tfvars line 1:
   1: {

An argument or block definition is required here.

Has debug logging been enabled?

  • [x] Yes, the ACTIONS_STEP_DEBUG secret was set to true when capturing the workflow log above. I understand that if I have not done this, I may not receive a response.

bjacoby-rn avatar Jun 03 '25 18:06 bjacoby-rn

Thanks for creating an issue @bjacoby-rn, this does appear to be a problem with v2.0.0

dflook avatar Jun 03 '25 18:06 dflook

I believe this is fixed in v2.0.1

dflook avatar Jun 03 '25 20:06 dflook

Hey, awesome! We'll test it shortly.

bjacoby-rn avatar Jun 10 '25 13:06 bjacoby-rn

We tested it and it works

bjacoby-rn avatar Jul 15 '25 14:07 bjacoby-rn