Migrating: how to ensure that you don't run terraform instead of tofu or vice versa? #1845
Replies: 4 comments 2 replies
-
As of OpenTofu 1.8 you will be able to rename your .tf files to .tofu, which will only work with OpenTofu. Unfortunately, I know of no way to verify the reverse (only Terraform). |
Beta Was this translation helpful? Give feedback.
-
While currently there's no native option that'll allow you to easily tell whether your current configuration is of OpenTofu or Terraform, there are some possible workarounds, that are not full proof
However, I would recommend being more explicit, and once OpenTofu 1.8 version is released, to switch your |
Beta Was this translation helpful? Give feedback.
-
While it won't enforce one or the other, using something like asdf may make it easier to manage which versions of which each root module uses and expects. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the comments everyone! What about this... from the department of awful hacks? :)
Of course it will fall trough if the user is calling this config using terraform while also executing tofu in another shell. Oh, well. I'm sure some nice combination of pgrep and pstree can exclude all processes that are not parent pids of the current shell, but I'll leave that bit of goldplating for another day. |
Beta Was this translation helpful? Give feedback.
-
We've started to migrate some configurations from Terraform to Opentofu, and it mostly just works. Thanks everyone!
Now, it will take us some time to migrate and redeploy all our Terraform configurations to Opentofu. For the period until that migration is completed, where we use Opentofu for some configurations and Terraform for others, I wish to ensure that I don't by mistake use the wrong tool somewhere. E.g use Opentofu for a Terraform configuration, or vice versa.
Is there any support in the language to validate and assert which client is used to execute the current configuration?
I'm aware of
required_providers { required_version ... }
but it is implementation independent. Any other options?Beta Was this translation helpful? Give feedback.
All reactions