Search code examples
azure-aksterraform-provider-azure

terraform create AKS use existing application gateway seem to be broken


I'm pretty sure there's a recent change? seems I can't use existing app gateway as AGIC for aks anymore in terraform

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
    

    }

the error message keeps saying


│ 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

Solution

  • Thank You stephybun for your suggestion over the GitHub Disccusion related to same issue. Posting this as an asnwer to help other community member as well.

    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.

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

    Even you can follow this Microsoft Documennt which mention the same Enable the AGIC add-on in existing AKS cluster you only require gateway_id