itsource

푸른색 클라우드 제공자에 개인 링크를 생성하려고 할 때 발생하는 문제

mycopycode 2022. 11. 4. 21:33
반응형

푸른색 클라우드 제공자에 개인 링크를 생성하려고 할 때 발생하는 문제

Azure에서 가상 시스템을 생성하는 테라폼 스크립트를 개발하고 개인 링크를 사용하여 Azure Postgresql 인스턴스에 연결하려고 합니다.항상 다음 오류가 발생합니다.

Error: creating Private Endpoint "n4gx6y-endpoint" (Resource Group "PGSQLResourceGroup"): 
network.PrivateEndpointsClient#CreateOrUpdate: 
Failure sending request: StatusCode=400 -- Original Error: 
Code="IncorrectPrivateLinkServiceConnectionGroupId" 
Message="Call to Microsoft.DBforPostgreSQL/servers failed. 
Error message: Private Link Service Connection Group Id is 
incorrect for Azure Database for PostgreSQL" Details=[]

  on main.tf line 68, in resource "azurerm_private_endpoint" "example":
  68: resource "azurerm_private_endpoint" "example" {

스크립트는 다음과 같습니다.

# -*- mode: hcl; coding: utf-8; -*-
# vim: set syntax=hcl fileencoding=utf-8

terraform {
  required_version = ">= 0.12, < 0.13"
}

provider "azurerm" {
  version                 = ">=2.20"
  subscription_id         = var.subscription_id
  client_id               = var.client_id
  client_certificate_path = var.client_certificate_path
  tenant_id               = var.tenant_id
  features {}
}

provider "random" {
  version = "~> 2.3"
}

resource "random_string" "random" {
  length  = 6
  special = false
  upper   = false
}

resource "azurerm_resource_group" "grp" {
  name     = "PGSQLResourceGroup"
  location = var.location

  tags = {
    environment = "Terraform Demo"
  }
}

resource "azurerm_virtual_network" "example" {
  name                = "${random_string.random.result}-network"
  address_space       = ["10.0.0.0/16"]
  location            = azurerm_resource_group.grp.location
  resource_group_name = azurerm_resource_group.grp.name
}

resource "azurerm_subnet" "example" {
  name                                           = "${random_string.random.result}-subnet"
  resource_group_name                            = azurerm_resource_group.grp.name
  virtual_network_name                           = azurerm_virtual_network.example.name
  address_prefixes                               = ["10.0.1.0/24"]
  enforce_private_link_endpoint_network_policies = true
}

resource "azurerm_postgresql_server" "example" {
  name                = "${random_string.random.result}-pg"
  location            = azurerm_resource_group.grp.location
  resource_group_name = azurerm_resource_group.grp.name

  sku_name = "GP_Gen5_2"

  backup_retention_days        = 7
  geo_redundant_backup_enabled = false
  storage_mb                   = 51200
  auto_grow_enabled            = true
  administrator_login          = "mysqladmin"
  administrator_login_password = "H@Sh1CoR3!"
  version                      = "11"
  ssl_enforcement_enabled      = true
}

resource "azurerm_private_endpoint" "example" {
  name                = "${random_string.random.result}-endpoint"
  location            = azurerm_resource_group.grp.location
  resource_group_name = azurerm_resource_group.grp.name
  subnet_id           = azurerm_subnet.example.id

  private_service_connection {
    name                           = "${random_string.random.result}-privateserviceconnection"
    private_connection_resource_id = azurerm_postgresql_server.example.id
    subresource_names              = ["postgresServer"]
    is_manual_connection           = false
  }
}

여기 Postgres와 Mariadb의 대본이 같은 github repo가 있습니다.Postgres에서만 에러가 발생.

https://github.com/kiklop74/terraform-private-link-issue

이 문제는 실제로 스크립트의 이 부분과 관련되어 있습니다.

  private_service_connection {
    name                           = "${random_string.random.result}-privateserviceconnection"
    private_connection_resource_id = azurerm_postgresql_server.example.id
    subresource_names              = ["postgresServer"] # <-- HERE!
    is_manual_connection           = false
  }

프라이빗 링크용으로 지원되는 각 Azure 관리 서비스에는 하드 코드된 서브 리소스 이름이 있습니다.MariaDB 인스턴스의 경우mariadbServer포스트그레스에게는postgresqlServer제가 잘못 배치했습니다.postgresServer그냥 제멋대로의 가치라고 생각하면서요

private_service_connection {
  name                           = "${random_string.random.result}- 
  privateserviceconnection"
  private_connection_resource_id = azurerm_postgresql_server.example.id
  subresource_names              = ["postgresqlServer"] # <-- HERE!
  is_manual_connection           = false

}

언급URL : https://stackoverflow.com/questions/63419749/issues-when-trying-to-create-private-link-on-azure-cloud-provider

반응형