terraform-switcher icon indicating copy to clipboard operation
terraform-switcher copied to clipboard

OpenTF Support

Open cameronattard opened this issue 1 year ago • 9 comments

Is your feature request related to a problem? Please describe. Per https://opentf.org/announcement, a new fork of Terraform, OpenTF is being created.

Describe the solution you'd like Allow using tfswitch to install and manage OpenTF versions in addition to Terraform versions.

cameronattard avatar Aug 29 '23 00:08 cameronattard

Wouldn't something like the --mirror flag work for opentf ?

https://github.com/warrensbox/terraform-switcher#use-custom-mirror

nitrocode avatar Sep 05 '23 16:09 nitrocode

Wouldn't something like the --mirror flag work for opentf ?

Hey @nitrocode - not quite.
Although we are looking to be fully compatible with legacy Terraform, the binary name, command (terraform vs opentf) are all going to be different.

roni-frantchi avatar Sep 11 '23 06:09 roni-frantchi

Hey folks! tofu support would be indeed quite useful. WDYT about separating managers and introducing the tool to manage tofu versions only? So it'd be an implementation of tfswitch interface/CLI commands, but called tofuswitch.

The main motivation: to separate concerns because tofu shall be treated as a standalone software independent of terraform when it comes to distribution. It'd enable for clean migration of CI pipelines etc.

kislerdm avatar Sep 21 '23 10:09 kislerdm

Same issue that affects listing versions in mirrors will also affect opentofu since there isn't a single non-paginated url containing every opentofu release.

Related issue

  • https://github.com/warrensbox/terraform-switcher/issues/311

nitrocode avatar Nov 12 '23 14:11 nitrocode

An option might be to switch from downloading terraform releases from the hashicorp page and download instead directly from github. Then it would be fairly simple to download the files from opentofu instead. The version check would then have to hit the github rest api or have an index url file passed in as an argument.

https://github.com/opentofu/opentofu/releases https://github.com/hashicorp/terraform/releases

nitrocode avatar Nov 12 '23 14:11 nitrocode

I made a page here that seems to line up similar to the terraform release page

https://nitrocode.github.io/opentofu/

nitrocode avatar Jan 04 '24 16:01 nitrocode

We'll probably need a way of overriding the versionPrefix since opentofu's prefix is tofu_

It might also be nice to override the rest of these too.

https://github.com/warrensbox/terraform-switcher/blob/d7dfd1b44605b095937e94b981d24305b858ff8c/main.go#L40-L49

https://github.com/warrensbox/terraform-switcher/blob/d7dfd1b44605b095937e94b981d24305b858ff8c/lib/install.go#L15-L22

nitrocode avatar Jan 04 '24 17:01 nitrocode

I'm interested in this issue, as we use tfswitch (or terraform-switcher ;) ) in Terrareg.

Once concern I could imagine is that, you're using Hashicorp's HCL library for obtaining the constraint from a terraform {} block: https://github.com/warrensbox/terraform-switcher/blob/d7dfd1b44605b095937e94b981d24305b858ff8c/main.go#L430-L435

Do we know if OpenTofu are sticking with this format (are they planning on changing the name at some point?) and I assume they have their own fork of the libraries: https://github.com/warrensbox/terraform-switcher/blob/d7dfd1b44605b095937e94b981d24305b858ff8c/main.go#L30

Edit: It looks like OpenTofu are still using hashicorp's hcl library and that library hasn't changed it's license.

MatthewJohn avatar Feb 24 '24 05:02 MatthewJohn

Do we know if OpenTofu are sticking with this format (are they planning on changing the name at some point?)

https://opentofu.org/

Can I use OpenTofu as a drop-in replacement for Terraform? Is OpenTofu suitable for production use?

Right now, OpenTofu is a drop-in replacement for Terraform, as it's compatible with Terraform versions 1.5.x and most of 1.6.x. You don’t need to make any changes to your code to ensure compatibility.

Hopefully OpenTofu isn't going to break core features and syntax compatibility in any near future 🤞🏻

yermulnik avatar Feb 24 '24 12:02 yermulnik

@cameronattard @nitrocode @MatthewJohn at this moment if you need to have a support of Terraform as well as OpenTofu (and Terragrunt :) ) in one tool you can use https://github.com/tofuutils/tenv which my team wrote some months ago. A lot of users switched to that tool to unify version management in the world of Terraform.

You're welcome to open any issues or contribute to tenv.

kvendingoldo avatar Apr 02 '24 22:04 kvendingoldo

@kvendingoldo While I have nothing against tenv (I tried it myself and, well, I prefer tfswitch, that I can run w/o any args to get just what I need — to switch to latest TF version allowed by the version constraint), I would like to ask to refrain from posting misleading info like «A lot of users switched to that tool to unify version management in the world of Terraform».

tenv: image tfswitch: image

Please be respectful and mindful.

PS: To the extent possible we'll make our best to look into OpenTofu and Terragrunt support to be implemented in tfswitch (though it is not a high-priority task at the moment I think). PRs are welcome since tfswitch has gain some energy lately.

yermulnik avatar Apr 02 '24 23:04 yermulnik

The tenv doesn't help me unfortunately because it's not the cli that I'd need here.

Atlantis (and other apps) uses the underlying terraform-switcher's go libs so those would need to be updated so we can keep the implementation of how atlantis autoupdates terraform the same as how it could autoupdate opentofu.

nitrocode avatar Apr 03 '24 21:04 nitrocode

Atlantis (and other apps) uses the underlying terraform-switcher's go libs so those would need to be updated so we can keep the implementation of how atlantis autoupdates terraform the same as how it could autoupdate opentofu.

Thanks for the update and details. Is what you're referring to related to https://github.com/warrensbox/terraform-switcher/issues/192 by any chance? I mean how the Atlantis (and other apps) utilizes tfswitch as a library?

While we're a bit short on human power to implement OpenTofu support, we welcome contributions and we'll try our best to review them as fast as our capacity allows.

yermulnik avatar Apr 03 '24 21:04 yermulnik

@nitrocode jfi, tenv provides golang package that you can use without cli just for tofu, because tfswitch does not support it. You can try to use it, but anyway i've got your point :)

kvendingoldo avatar Apr 04 '24 13:04 kvendingoldo

It's unrelated to the issue you mentioned.

See this issue for the lower level details https://github.com/runatlantis/atlantis/issues/4339.

nitrocode avatar Apr 05 '24 03:04 nitrocode