Terraform vs OpenTofu


In the documentation you advise OpenTofu as well. I havent’ used it actively yet, due to it’s current alpha status. But how can I switch from terraform 1.5.5 to OpenTofu when it’s releasing it’s first stable version?

What is BoltOps planning for this?
Will it be an environment or project variable I can set, or will it be rewiring the symlink from /opt/homebrew/bin/terraform to the correct opentofu binary?

Terraspace automatically detects the terraform binary.

  1. tofu (highest precedence)
  2. terraform

Here’s the source code where this happens:

However, there was a recent report that there might be a bug: Migration from Terraform to OpenTOFU results in Inconsistent dependency lock file error · Issue #338 · boltops-tools/terraspace · GitHub

When I tested it I did not run into this. tofu was automatically detected just fine. Believe there’s some thing weird happening if you have an existing state file and or cache. Unsure, as I only looked into it briefly.

The workaround is to symlink. Though, would like to understand the issue better.

Ideally, should automatically be detected.

There’s also an TS_TERRAFORM_BIN env that you can use to override.

Unsure when will take a closer look. Will consider PRs for:

Also note: /opt/terraspace does not provide terraform. You bring your own terraform and provide the terraform binary.

The standalone installers only provide ruby and terraspace. In generally, I recommend installing ruby and terraspace as a gem.

Excellent news, thanks.
I’m currently experimenting with both on my system and we’re currently still using terraspace 2.2.14. I think it’s not part of that code yet. So I’ll be focussed when doing a terraspace upgrade to avoid unexpected behavior.

This works perfectly on the cli. We’re having some conversion issues moving from terrorfarm to tofu. Is there any chance that you could put this into the app.rb file as an option?

So I found a loophole to make it work, not sure if it’s ment to be used like this. I forced the use of terraform instead of tofu via an ENV setting in the boot.rb:

I created a config/boot.rb and put an ENV[‘’] in there to force using homebrew’s terraform (on a mac):
ENV['TS_TERRAFORM_BIN'] = '/opt/homebrew/bin/terraform'

Where can I find the terraspace documentation so I could perform a tofu/terraform pr against it?

Kind regards, Jelle

Sure. That’s a use case for boot hooks. Glad that you figured it out and posted it for others.

Also, there was a fix to the terraform_bin lookup logic.

Had missed 2 spots and a user found them :+1: So the solution above is not needed anymore. Still, it’s good to know :smile: boot hooks for the win!

For posterity: Contributing - Terraspace