Testing against multiple versions of Terraform using SDKv2

As far as I understood from announcements, SDKv2 is supposed to facilitate acceptance testing against different versions of Terraform (v12 & v13). How can I achieve that, other than creating different docker containers with different tf versions installed?

It might be also useful to know how to get actual terraform version, that calls the provider.

The test framework picks the terraform binary to use when running tests in a hierarchy:

  • If you have TF_ACC_TERRAFORM_PATH set, it will call that binary.
  • If you don’t have TF_ACC_TERRAFORM_PATH set, it will try to find terraform in your PATH. If it can, it’ll use that binary.
  • If it still can’t find Terraform, (I believe) it downloads and installs the version of Terraform specified by the TF_ACC_TERRAFORM_VERSION environment variable, though my (potentially out of date) understanding is that that may be problematic in certain situations involving parallelism.

If I were to make a suggestion for how to run multiple versions of Terraform against your acceptance tests, I would download each of the binaries, maybe to /base/dir/terraform0.12.26/terraform, /base/dir/terraform0.13.0/terraform, /base/dir/terraform0.13.2/terraform, or whatever, and then specify the path to the binary for the version you want to use using TF_ACC_TERRAFORM_PATH.