Skip to content

Commit

Permalink
allow private dns for web app routing
Browse files Browse the repository at this point in the history
  • Loading branch information
stephybun committed Feb 27, 2024
1 parent 3f85dee commit a812c41
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
Required: true,
ValidateFunc: validation.Any(
dnsValidate.ValidateDnsZoneID,
privatezones.ValidatePrivateDnsZoneID,
validation.StringIsEmpty,
),
},
Expand Down

0 comments on commit a812c41

Please sign in to comment.