Override provider version in Terraform test

Does anyone know any way to override the provider version in terraform test? We’d like to be able to test different versions against our modules in out unit/integration tests before using it.

My initial thought was to use the mock_provider block in the test file but it doesnt have a version attribute, seems like it just takes the version from the provider.tf file.

Hi @canuski, unfortunately it isn’t possible to use multiple versions of a provider within any part of Terraform. The testing framework is restricted by the same requirements that prevent this within regular Terraform.

You can see a feature request for this issue here: terraform test overriding provider version · Issue #35867 · hashicorp/terraform · GitHub. Enough interest on that issue could trigger a larger investigation into removing this requirement more generally from Terraform. Thanks!

1 Like