hashicorp / setup-terraform

Sets up Terraform CLI in your GitHub Actions workflow.
https://developer.hashicorp.com/terraform/tutorials/automation/github-actions
Mozilla Public License 2.0
1.35k stars 237 forks source link

With upgrade to v3, terrafrom init in github actions fails with wrapper enabled #373

Closed pribanerjee closed 10 months ago

pribanerjee commented 10 months ago

We just upgraded to hashicorp/setup-terraform@v3 for our GitHub actions and it started failing in terraform init step with below error

/actions-runner/_temp/e6023f8c-517d-4123-8609-5827ed8f73a7/terraform:4342
      this._parser?.end()
                   ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:10[27](https://github.com/OttoPaymentHub/bigfin_api-gateway/actions/runs/6704783026/job/18217882380#step:9:28):10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
Error: Process completed with exit code 1.

Terraform Configuration Files:

      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v3
        with:
          terraform_version: '1.6.0'
          terraform_wrapper: true

It only works when we disable the terraform_wrapper, which is not expected as we would like to work with exit codes.

Please look into the issue.

austinvalle commented 10 months ago

Hey there @pribanerjee 👋🏻 ,

Can you confirm what version of NodeJS is running on your action runner? v3 was updated to run with node20 and the error presented looks like the NodeJS version running doesn't support optional chaining (introduced in Node 14).

pribanerjee commented 10 months ago

Hey there @pribanerjee 👋🏻 ,

Can you confirm what version of NodeJS is running on your action runner? v3 was updated to run with node20 and the error presented looks like the NodeJS version running doesn't support optional chaining (introduced in Node 14).

Hey @austinvalle , we are using Node16 in our runner.So unless we upgrade to node20, we need to use with wrapper disabled?

pribanerjee commented 10 months ago

Also currently node16 is default version of the actions runners

austinvalle commented 10 months ago

The v3 release was in preparation for node16 being deprecated next year, so v3.0.0 and above will all be aimed at supporting Node20. It looks like the action runners were also preparing for that deprecation, but then reverted it after.

If you need support for versions prior to node20 you could continue using v2 as most changes between v2 and v3 are version bumps.

github-actions[bot] commented 3 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.