ASH
ASH

Reputation: 655

Terraform running in Azure Pipeline attempting to install azcli provider

I'm running Terraform in an Azure Pipeline (something I have experience of doing) and for some reason the init step is attempting to install a provider for azcli, which I don't think exists. This does not happen when I run Terraform on my local machine.

My providers file is:

terraform {
  required_version = ">=0.13"

 backend "azurerm" {
   container_name = "tfstate"
   key            = "terraform.tfstate"
 }

 required_providers {
   grafana = {
   source  = "grafana/grafana"
   version = "=1.5.0"
   }
  }
}

This is the error I'm seeing:

Terraform init error

I'm not sure why Terraform is trying to install the azcli provider; I don't think it even exists. Has anyone seen this before?

Upvotes: 1

Views: 964

Answers (1)

Christian Pearce
Christian Pearce

Reputation: 1026

Terraform searches directly and indirectly for providers when initialization. It is possible there is a mistake in the resource name or provider definition. Search your codebase for azcli.

▶ cat .\main.tf
resource "azcli_test" "test" {
    test = "true"
}

~\projects\test\t5                                                                                                                            ◷ 10:10:21 AM
▶ C:\Users\pearcec\bin\terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/azcli...

Error: Failed to install provider

Error while installing hashicorp/azcli: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/azcli

or

~\projects\test\t5                                                                                                                            ◷ 10:10:23 AM
▶ cat .\main.tf
provider "azcli" {
  features {}
}

~\projects\test\t5                                                                                                                            ◷ 10:13:41 AM
▶ C:\Users\pearcec\bin\terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/azcli...

Error: Failed to install provider

Error while installing hashicorp/azcli: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/azcli

or

▶ cat .\main.tf
terraform {
  required_providers {
    azcli = {
      source  = "-/azcli"
    }
  }
}

~\projects\test\t5                                                                                                                            ◷ 10:16:09 AM
▶ C:\Users\pearcec\bin\terraform init

Initializing the backend...

Initializing provider plugins...
- Finding latest version of -/azcli...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider -/azcli:
provider registry registry.terraform.io does not have a provider named
registry.terraform.io/-/azcli

Upvotes: 0

Related Questions