minamijoyo / tfmigrate

A Terraform / OpenTofu state migration tool for GitOps
MIT License
1.12k stars 57 forks source link

Allow use of OpenTofu by setting TFMIGRATE_EXEC_PATH to tofu #164

Closed minamijoyo closed 10 months ago

minamijoyo commented 10 months ago

Part of #162

To use OpenTofu, a community fork of Terraform, you need to set the environment variable TFMIGRATE_EXEC_PATH to tofu


To support OpenTofu, I've relaxed a regular expression so that the output of the tofu version command can be parsed at least. Also, to use the tofu command for testing, read environment variables at the time of initializing the TerraformCLI instance.

This fix optimistically assumes that Terraform and OpenTofu features and version numbers are compatible, but the implementations will diverge and eventually become incorrect as time goes on. I think some abstractions, such as capability, will be needed before adding new features depending on Terraform 1.6+.

OpenTofu has yet to be released as stable, but an alpha version is available. I've added it to the test matrix.