postgresql - Terraform 为 azure Postgressql 灵活服务器配置数据库角色引发错误

标签 postgresql azure azure-devops terraform terraform-provider-azure

我已经使用 terraform 将 Azure PostgresSQL 灵活服务器部署为 PAAS,运行良好。现在我想使用 terraform 创建不同的角色并为数据库分配不同的权限。但它引发了下面提到的错误。请查看并建议我正确的 terraform 配置和解决方案所需的提供程序。

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

最佳答案

使用 terraform 创建不同角色并为数据库分配不同权限的解决方案。

  1. 在子模块中创建了一个“provider.tf”文件并定义 pssql 模块 enter image description here

  2. 在根模块 porvider.tf 文件旁边定义 postgresql 提供程序 block 。

  3. enter image description here

  4. 运行地形计划

  5. 运行 terraform apply。

关于postgresql - Terraform 为 azure Postgressql 灵活服务器配置数据库角色引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74260702/

相关文章:

linux - 使用 dotnet 的带有托管 Linux 预览版的 Nuget 包的 VSTS 发布管理

node.js - 使用 Node db-migrate 在事务中禁用包装迁移

postgresql - postgresql 的用户名和密码?

postgresql - 如何根据其他列在postgresql中添加一列

.net - azure 搜索 search.ismatch 忽略末尾的 "1"

sql-server - 如果使用 View ,更新 Azure 搜索文档是否会更新我的数据库

azure - 从 Azure 函数/逻辑应用访问本地 Active Directory

git - 如何在不知道 "exact"名称的情况下恢复 Azure DevOps git 中已删除的分支

sql - PostgreSQL - 显示上年+当年周数据

azure - 在 Azure Devops 中部署具有多个 Webjobs 的 WebAPI 项目