When running the terraform init, there is provider conflict between hashicorp/azuredevops (which does not exist) and the right one microsoft/azuredevops
$ terraform init
Initializing the backend...
Initializing modules...
Initializing provider plugins...
- Finding microsoft/azuredevops versions matching "~> 1.0.1"...
- Finding mastercard/restapi versions matching "~> 1.18.2"...
- Finding latest version of hashicorp/azuredevops...
- Installing microsoft/azuredevops v1.0.1...
- Installed microsoft/azuredevops v1.0.1 (signed by a HashiCorp partner, key ID 6F0B91BDE98478CF)
- Installing mastercard/restapi v1.18.2...
- Installed mastercard/restapi v1.18.2 (self-signed, key ID DCB8C431D71C30AB)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
β·
β Error: Failed to query available provider packages
β
β Could not retrieve the list of available versions for provider hashicorp/azuredevops: provider registry registry.terraform.io does not have a provider named
β registry.terraform.io/hashicorp/azuredevops
β
β Did you intend to use microsoft/azuredevops? If so, you must specify that source address in each module which requires that provider. To see which modules are currently
β depending on hashicorp/azuredevops, run the following command:
β terraform providers
I think Terraform isnβt correctly connecting the provider definition you have for Azure DevOps to the source you provide in the alternate module, which I can investigate and fix once we have the bug report.
In the meantime and as a workaround, if you place the azuredevops definition into the required_providers block in your main configuration (within module_to_test/main.tf) does that resolve the conflict? I will test that myself shortly to confirm, but you might get to it before I do.
$ terraform init
Initializing the backend...
Initializing modules...
β·
β Error: Provider type mismatch
β
β on tests\unit.tftest.hcl line 2:
β 2: provider "azuredevops" {
β
β The provider "azuredevops" in tests\unit.tftest.hcl represents provider "registry.terraform.io/microsoft/azuredevops", but "azuredevops" in the root module represents
β "registry.terraform.io/hashicorp/azuredevops".
β
β This means the provider definition for "azuredevops" within tests\unit.tftest.hcl has been referenced by multiple run blocks and assigned to different provider types.
$ terraform providers
β·
β Error: Provider type mismatch
β
β on tests\unit.tftest.hcl line 2:
β 2: provider "azuredevops" {
β
β The provider "azuredevops" in tests\unit.tftest.hcl represents provider "registry.terraform.io/microsoft/azuredevops", but "azuredevops" in the root module represents
β "registry.terraform.io/hashicorp/azuredevops".
β
β This means the provider definition for "azuredevops" within tests\unit.tftest.hcl has been referenced by multiple run blocks and assigned to different provider types.
Iβll fill up a new issue on the tracker soon and let you know here.
My bad, I read too quickly your first answer, sorry!
Itβs indeed working but does not map correctly the context. The azuredevops provider is required by a side module which output is used as input of the current one (the current having no need at all for the azuredevops provider).
But this is a good workaround, thanks!
Yes, Iβd still consider this a bug but itβs good we have a workaround. If you have time itβd be great if you could file an issue - they have more impact coming from external users. Itβll also be easier for you to get notified once a fix is in place.
Otherwise, I can create one later to track a fix for this if you donβt have time.