gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
7.94k stars 965 forks source link

Error parsing terraform version when tofu is installed as tofu-bin #2819

Closed wyardley closed 9 months ago

wyardley commented 9 months ago

Describe the bug There may not be a good fix for this, but what I noticed is that if I set TERRAGRUNT_TFPATH to tofu, Terragrunt will correctly find / use opentofu instead of Terraform, but then barfs when it finds a wrapper unless TERRAGRUNT_TFPATH is also set to tofu-bin. This is an easy fix once you figure out what the issue is (either by updating TERRAGRUNT_TFPATH, or by configuring the setupu-opentofu action to not use the wrapper), but a bit tricky to debug in a CI environment. Maybe because of a symlink?

To Reproduce

    - uses: actions/checkout@v4
    - uses: opentofu/setup-opentofu@v1
    - uses: autero1/action-terragrunt@v1.3.2
      with:
        terragrunt_version: 0.53.8
$ export TERRAGRUNT_DISABLE_INIT=true 
$ export TERRAGRUNT_NON_INTERACTIVE=true
$ export TERRAGRUNT_TFPATH=tofu
$ terragrunt --terragrunt-working-dir "$DIR" run-all init

Expected behavior Terragrunt to initialize

Nice to have

-11-30T23:44:13Z level=error msg=Module /home/runner/work/tofu/tofu/environments/xxx/network has finished with an error: Unable to parse Terraform version output: [command]/home/runner/work/_temp/37640e4d-40fa-411b-af9d-b13569f189a9/tofu-bin --version OpenTofu v1.6.0-beta1 on linux_amd64

Versions

Additional context

2818 / #2817 are not really related, other than it being why I dug into the regex, but I opened it anyway

wyardley commented 9 months ago

I went ahead and created this, even though I figured out the answer, in case finding this in search helps someone else. Closing