diff --git a/internal/services/containers/kubernetes_cluster_other_resource_test.go b/internal/services/containers/kubernetes_cluster_other_resource_test.go index 3faf06054d8d..21703a2a006b 100644 --- a/internal/services/containers/kubernetes_cluster_other_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_other_resource_test.go @@ -906,6 +906,22 @@ func TestAccKubernetesCluster_webAppRouting(t *testing.T) { }) } +func TestAccKubernetesCluster_webAppRoutingPrivateDNS(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") + r := KubernetesClusterResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.webAppRoutingPrivateDNS(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("web_app_routing.0.web_app_routing_identity.#").HasValue("1"), + ), + }, + data.ImportStep(), + }) +} + func TestAccKubernetesCluster_azureMonitorKubernetesMetrics(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test") r := KubernetesClusterResource{} @@ -2921,6 +2937,45 @@ resource "azurerm_kubernetes_cluster" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) } +func (KubernetesClusterResource) webAppRoutingPrivateDNS(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-aks-%d" + location = "%s" +} + +resource "azurerm_private_dns_zone" "test" { + name = "privatelink.%s.azmk8s.io" + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_kubernetes_cluster" "test" { + name = "acctestaks%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + dns_prefix = "acctestaks%d" + + default_node_pool { + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + } + + identity { + type = "SystemAssigned" + } + + web_app_routing { + dns_zone_id = azurerm_private_dns_zone.test.id + } +} + `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) +} + func (KubernetesClusterResource) customCATrustEnabled(data acceptance.TestData, enabled bool) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/internal/services/containers/kubernetes_cluster_resource.go b/internal/services/containers/kubernetes_cluster_resource.go index a914042cd1e8..7654704fe7a8 100644 --- a/internal/services/containers/kubernetes_cluster_resource.go +++ b/internal/services/containers/kubernetes_cluster_resource.go @@ -489,6 +489,7 @@ func resourceKubernetesCluster() *pluginsdk.Resource { Required: true, ValidateFunc: validation.Any( dnsValidate.ValidateDnsZoneID, + privatezones.ValidatePrivateDnsZoneID, validation.StringIsEmpty, ), },