"Error: Failed to query available provider packages" for non-HashiCorp provider betr-io/mssql

I would like to use the betr-io/mssql into my Terraform environment which is on Azure DevOps.

This is my providers.tf

provider "azurerm" {
  alias           = "main"
  tenant_id       = var.tenant_id
  subscription_id = var.providers_azurerm["main"].subscription_id

  features {
    key_vault {
      purge_soft_delete_on_destroy = true
      recover_soft_deleted_key_vaults = true
    }
  }
}

provider "azurerm" {
  tenant_id       = var.tenant_id
  subscription_id = var.providers_azurerm["subscription"].subscription_id
  
  features {
    key_vault {
      purge_soft_delete_on_destroy = true
      recover_soft_deleted_key_vaults = true
    }
  }
}

provider "betrio-mssql" {
  debug = "false"
}

This is the terraform code in the ‘main.tf’

locals {
}

terraform {
  backend "azurerm" {
  }
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
    }
    betrio-mssql = {
      source = "betr-io/mssql"
      version = "0.2.1"
    }
  }
}

In the resource I’m having …

resource "mssql_user" "auser" {
  provider = betrio-mssql
  
  server {
    host = var.sql_host_name
    database = var.sqldb_name
  }
  username = var.username
  password = random_password.password[0].result
  roles    = [ "db_owner" ]
}

But still getting this error in the Init

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/betrio-mssql: provider registry registry.terraform.io does not
│ have a provider named registry.terraform.io/hashicorp/betrio-mssql
│ 
│ All modules should specify their required_providers so that external
│ consumers will get the correct providers when using a module. To see which
│ modules are currently depending on hashicorp/betrio-mssql, run the
│ following command:
│     terraform providers

Any ideas what I’m doing wrong?

I couldn’t find a lot of samples on this issue. So posting here, what I did find was tried but no success. If people know better ways to create users in databases please feel free.

Not exactly what you are looking for but you may want to check this thread -

Terraform reports error “Failed to query available provider packages” - Stack Overflow

1 Like

Ok, repeating the block in every main.tf where i’m calling a resource or module fixes it.
Thx, great help.

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
    }
    betrio-mssql = {
      source = "betr-io/mssql"
      version = "0.2.1"
    }
  }
}

Hi @HL-Sibelco,

I’m glad you found the answer. In case it’s helpful to others who find this topic in future, I just wanted to note that you specifically need to declare the required_providers entry in each module that includes references to that provider.

“References to that provider” includes:

  • The provider "betrio-mssql" block you showed.
  • Any resource that has provider = betrio-mssql assigned.
  • Any module call that has a providers argument which includes mentions of betrio-mssql.

The required_providers entry is how Terraform understands what the short name betrio-mssql is intended to mean inside this particular module. Each module has its own namespace of local provider names, because otherwise it wouldn’t work to call into a module written by someone else who selected a different local name for that provider.

2 posts were split to a new topic: Unable to install provider betr-io/mssql