0

I have deployed Azure PostgresSQL Flexible server as a PAAS using terraform which is working fine . Now I want to create different Roles and assign different privilege's for the database using terraform. But it is raising the error which is mentioned bellow. Please have a look and suggests me the proper terraform configuration and required providers for the solution .

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/postgresql: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/postgresql
Did you intend to use cyrilgdn/postgresql? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/postgresql, run the following command:
terraform provider

terraform {
  required_version = ">= 1.1.6"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">=3.20.0"
    }

    postgresql = { 
      source  = "cyrilgdn/postgresql"
      version = "1.15.0"
    }

  }
}

provider "postgresql" {
  host            = module.az_pssql_flex.azurerm_postgresql_flexible_server
  port            = 5432
  database        = var.databases_names
  username        = ""
  password        = ""
  sslmode         = "require"
  connect_timeout = 120
  superuser       = false

}

enter image description here

Marko E
  • 13,362
  • 2
  • 19
  • 28
eku
  • 11
  • 1
  • 2
  • 6
  • whats the output of `terraform providers` – Chris Doyle Oct 31 '22 at 08:51
  • ` Error: Failed to query available provider packages │ │ Could not retrieve the list of available versions for provider hashicorp/postgresql: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/postgresql │ │ Did you intend to use cyrilgdn/postgresql? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on hashicorp/postgresql, run the following command: │ terraform providers ` – eku Oct 31 '22 at 09:03
  • `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` – eku Oct 31 '22 at 09:05
  • sounds like somewhere in your config or modules you have listed the source of postgres without the namespace so its just defaulting to hashicorp – Chris Doyle Oct 31 '22 at 09:06
  • Can you please provide a example conf – eku Oct 31 '22 at 09:09
  • Since you are using a non-official provider (i.e., postgresql) it was probably defined at the module level. You are referencing the module in your `postgresql` block. Check the module code and see if there are some `hashicorp/postgresql` module references and fix that. – Marko E Oct 31 '22 at 10:10
  • refer https://stackoverflow.com/questions/69190343/terraform-problem-to-define-cyrilgdn-postgresql-provider-properly – Swarna Anipindi Oct 31 '22 at 12:52
  • Thank you so much @Swarna for the instruction . I have created another "provider.tf" file in the child module(pssql mopdule) and define the pssql provider block beside the root module porvider.tf file. Now it works. – eku Oct 31 '22 at 16:16
  • posted the answer with same. Thank You. – Swarna Anipindi Oct 31 '22 at 17:46

1 Answers1

1

Solution to create different Roles and assign different privileges for the database using terraform.

  1. created an "provider.tf" file in the child module and define pssql module enter image description here

  2. Define the postgresql provider block beside the root module porvider.tf file.

  3. enter image description here

  4. run terraform plan

  5. run terraform apply.

Swarna Anipindi
  • 792
  • 2
  • 9