terraform create AKS 使用现有应用程序网关似乎已损坏

terraform create AKS use existing application gateway seem to be broken

我很确定最近有变化?似乎我不能再在 terraform

中将现有的应用程序网关用作 aks 的 AGIC
ingress_application_gateway {

      subnet_id    = var.ingress_agic_subnet == null ? null : data.azurerm_subnet.ingress_agic_subnet[0].id # existing subnet where I created App gateway
      gateway_id   = var.ingress_application_gateway_id #existing  app gateway ID
    

    }

错误信息一直在说


│ Error: Conflicting configuration arguments
│
│   with module.aks.azurerm_kubernetes_cluster.this,
│   on terraform-azurerm-lab3-aks\main.tf line 70, in resource "azurerm_kubernetes_cluster" "this":
│   70:       subnet_id    = var.ingress_agic_subnet == null ? null : data.azurerm_subnet.ingress_agic_subnet[0].id
│
│ "ingress_application_gateway.0.subnet_id": conflicts with ingress_application_gateway.0.gateway_id
╵
╷
│ Error: Conflicting configuration arguments
│
│   with module.aks.azurerm_kubernetes_cluster.this,
│   on terraform-azurerm-lab3-aks\main.tf line 73, in resource "azurerm_kubernetes_cluster" "this":
│   73:       gateway_id   = var.ingress_application_gateway_id
│
│ "ingress_application_gateway.0.gateway_id": conflicts with ingress_application_gateway.0.subnet_id

感谢 stephybun 对与同一问题相关的 GitHub 讨论提出的建议。将此作为答案发布以帮助其他社区成员。

The AKS API will create an Application Gateway for you based on the subnet_id or subnet_cidr provided, or you can BYO Application Gateway. As a result it isn't possible to specify both subnet_id and gateway_id since that would trigger conflicting behaviours in the API. Since you already have an existing Application Gateway the only property you need to set is the gateway_id.

参考:https://github.com/hashicorp/terraform-provider-azurerm/issues/15693

即使您可以按照此 Microsoft Documennt 进行操作,其中提到相同的 在现有 AKS 集群中启用 AGIC add-on 你只需要 gateway_id