Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenTofu support #2690

Closed
brikis98 opened this issue Aug 29, 2023 · 8 comments · Fixed by #2745
Closed

Add OpenTofu support #2690

brikis98 opened this issue Aug 29, 2023 · 8 comments · Fixed by #2745
Assignees
Labels
enhancement New feature or request

Comments

@brikis98
Copy link
Member

brikis98 commented Aug 29, 2023

Describe the solution you'd like
As recently announced, the OpenTofu fork should drop soon. We should make sure that Terragrunt supports it out of the box.

Here's an idea for an initial implementation: anywhere Terragrunt calls out to the terraform binary, we should update it to check for the terraform binary first; if that's not found, then try the tofu binary; and if that's not found, show an error (as we do today). Whatever we pick, we should mention in the debug log.

Describe alternatives you've considered
In theory, you can already use OpenTofu by using the terraform_binary config or --terragrunt-tfpath CLI flag or TERRAGRUNT_TFPATH env var, but those all require extra steps, whereas I'd like OpenTofu to "just work" with Terragrunt.

Additional context
OpenTofu should work as a "drop in" replacement for Terraform, so in theory, no other changes should be necessary. However, we should run our tests to make sure once the tofu binary is available for testing. One place where OpenTofu will differ is stdout and stderr output will say OpenTofu instead of Terraform; if Terragrunt is parsing that log output anywhere, we'll need to update the code accordingly.

This is just the initial implementation in the sense that it should be backward compatible. In the future, we can reverse the lookup order, and perhaps even drop support for terraform, but those would be significant breaking changes (especially the latter), so we'd want to see how things go with OpenTofu and what the community wants first.

Note on registry usage
HashiCorp recently did an update (one that was totally unannounced, BTW) to its Registry terms to say:

You may download providers, modules, policy libraries and/or other Services or Content from this website solely for use with, or in support of, HashiCorp Terraform.

Terragrunt uses go-getter to download modules specified in the source URL, and it's possible that URL points to the Terraform Registry. For now, Terragrunt only works with Terraform, so that is still inline with the terms. If we add support for OpenTofu, then in theory, anyone using Terragrunt with OpenTofu might be violating the registry terms.

Possible solutions:

  1. Cheapest/fastest: If we detect a registry source URL and tofu as the binary, give the user a warning.
  2. Better solution: If we detect a registry source URL and tofu as the binary, automatically use OpenTofu's registry (coming soon) instead of HashiCorp's.
@brikis98 brikis98 added the enhancement New feature or request label Aug 29, 2023
@lorengordon
Copy link
Contributor

lorengordon commented Aug 29, 2023

How about modifying the tfpath argument to support a list (presuming it doesn't support that already), and just adding opentf to the list?


Fwiw, personally and for my own teams, I'm likely to use an alias, or the terraform_binary config argument, or both!

@denis256 denis256 self-assigned this Aug 29, 2023
@skyzyx
Copy link

skyzyx commented Aug 30, 2023

From a technical perspective, I expect that it will be a no-op for the time being as OpenTF anticipates maintaining compat/interop for the foreseeable future. (However, OpenTF has stated that some functionality may be added to OpenTF that is a superset of what's in base Terraform. [source])

From a process perspective:

  1. If there is a bug in OpenTF that does not exist in Terraform (or vice-versa), will bug reports (as they pertain to this project) be treated equally on both platforms?

  2. Will testing be performed with code targeting both platforms?

  3. For OpenTF's potential future "superset" functionality, will that be treated as a first-class citizen?

@brikis98
Copy link
Member Author

brikis98 commented Sep 4, 2023

I just updated the issue description with:

Note on registry usage
HashiCorp recently did an update (one that was totally unannounced, BTW) to its Registry terms to say:

You may download providers, modules, policy libraries and/or other Services or Content from this website solely for use with, or in support of, HashiCorp Terraform.

Terragrunt uses go-getter to download modules specified in the source URL, and it's possible that URL points to the Terraform Registry. For now, Terragrunt only works with Terraform, so that is still inline with the terms. If we add support for OpenTF, then in theory, anyone using Terragrunt with OpenTF might be violating the registry terms.

Possible solutions:

  1. Cheapest/fastest: If we detect a registry source URL and opentf as the binary, give the user a warning.
  2. Better solution: If we detect a registry source URL and opentf as the binary, automatically use OpenTF's registry (coming soon) instead of HashiCorp's.

@brikis98
Copy link
Member Author

brikis98 commented Sep 4, 2023

From a technical perspective, I expect that it will be a no-op for the time being as OpenTF anticipates maintaining compat/interop for the foreseeable future. (However, OpenTF has stated that some functionality may be added to OpenTF that is a superset of what's in base Terraform. [source])

From a process perspective:

  1. If there is a bug in OpenTF that does not exist in Terraform (or vice-versa), will bug reports (as they pertain to this project) be treated equally on both platforms?

Yup. Until otherwise announced, we should support both platforms equally.

  1. Will testing be performed with code targeting both platforms?

Yes, we should test both platforms.

  1. For OpenTF's potential future "superset" functionality, will that be treated as a first-class citizen?

Probably, but hard to say until we know what that functionality is. I think we'll have to decide on a case by case basis, with input from the community.

@skyzyx
Copy link

skyzyx commented Sep 5, 2023

Your response is greatly appreciated.

This whole situation has created uncertainty at a time when we could really do without it. My company leverages several open-source and SaaS offerings in the Terraform ecosystem, and I've been reaching out across the ecosystem to understand where everyone is on this topic, and identifying what we need to watch out for.

Hoping for the very best from this whole situation, but planning ahead for the absolute worst.

@RobertKosten
Copy link

I've been using the unofficial dev snap OpenTF v1.6.0-dev, but even with --terragrunt-tfpath set to /snap/bin/opentf I get an error: Unable to parse Terraform version output: OpenTF v1.6.0-dev on linux_amd64. I'd say parsing that was bound to be brittle :-P

@brikis98 brikis98 changed the title Add OpenTF support Add OpenTofu support Sep 22, 2023
rsteube added a commit to carapace-sh/carapace-bin that referenced this issue Sep 29, 2023
@denis256 denis256 moved this from To do to In progress in Terragrunt Roadmap Oct 4, 2023
@denis256 denis256 mentioned this issue Oct 4, 2023
4 tasks
@denis256 denis256 moved this from In progress to Review in progress in Terragrunt Roadmap Oct 4, 2023
@github-project-automation github-project-automation bot moved this from Review in progress to Done in Terragrunt Roadmap Oct 6, 2023
@denis256
Copy link
Member

denis256 commented Oct 9, 2023

Released in https://github.com/gruntwork-io/terragrunt/releases/tag/v0.52.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

5 participants