diff --git a/azurerm/_modules/aks/vnet.tf b/azurerm/_modules/aks/vnet.tf index 8131a272..2cb5ae60 100644 --- a/azurerm/_modules/aks/vnet.tf +++ b/azurerm/_modules/aks/vnet.tf @@ -1,6 +1,6 @@ resource "azurerm_virtual_network" "current" { - count = var.network_plugin == "azure" ? 1 : 0 + count = var.network_plugin == "azure" ? 1 : 0 name = "vnet-aks-${terraform.workspace}-cluster" address_space = var.vnet_address_space @@ -9,12 +9,12 @@ resource "azurerm_virtual_network" "current" { } resource "azurerm_subnet" "current" { - count = var.network_plugin == "azure" ? 1 : 0 + count = var.network_plugin == "azure" ? 1 : 0 name = "aks-node-subnet" address_prefixes = var.subnet_address_prefixes resource_group_name = data.azurerm_resource_group.current.name virtual_network_name = azurerm_virtual_network.current[0].name - - service_endpoints = var.subnet_service_endpoints == [""] ? null: var.subnet_service_endpoints + + service_endpoints = length(var.subnet_service_endpoints) > 0 ? var.subnet_service_endpoints : null } diff --git a/azurerm/cluster/configuration.tf b/azurerm/cluster/configuration.tf index 634753c9..4d53b646 100644 --- a/azurerm/cluster/configuration.tf +++ b/azurerm/cluster/configuration.tf @@ -17,9 +17,11 @@ locals { dns_prefix = lookup(local.cfg, "dns_prefix", "api") - vnet_address_space = split(",", lookup(local.cfg, "vnet_address_space", "10.0.0.0/8")) - subnet_address_prefixes = split(",", lookup(local.cfg, "subnet_address_prefixes", "10.1.0.0/16")) - subnet_service_endpoints = split(",", lookup(local.cfg, "subnet_service_endpoints", "")) + vnet_address_space = split(",", lookup(local.cfg, "vnet_address_space", "10.0.0.0/8")) + subnet_address_prefixes = split(",", lookup(local.cfg, "subnet_address_prefixes", "10.1.0.0/16")) + + subnet_service_endpoints_lookup = lookup(local.cfg, "subnet_service_endpoints", "") + subnet_service_endpoints = local.subnet_service_endpoints_lookup != "" ? split(",", local.subnet_service_endpoints_lookup) : [] network_plugin = lookup(local.cfg, "network_plugin", "kubenet") network_policy = lookup(local.cfg, "network_policy", "calico")