diff --git a/main.tf b/main.tf index be99fa59..fa13e1af 100644 --- a/main.tf +++ b/main.tf @@ -104,6 +104,8 @@ resource "azurerm_kubernetes_cluster" "main" { tenant_id = var.rbac_aad_tenant_id } } + + dynamic "identity" { for_each = var.client_id == "" || var.client_secret == "" ? ["identity"] : [] @@ -141,6 +143,28 @@ resource "azurerm_kubernetes_cluster" "main" { } } } + + dynamic "maintenance_window" { + for_each = var.enable_maintenance_window ? ["maintenance_window"] : [] + content { + dynamic "allowed" { + for_each = var.maintenance_allowed + content { + day = allowed.value.day + hours = allowed.value.hours + } + } + + dynamic "not_allowed" { + for_each = var.maintenance_not_allowed + content { + start = not_allowed.value.start + end = not_allowed.value.end + } + } + } + } + network_profile { network_plugin = var.network_plugin dns_service_ip = var.net_profile_dns_service_ip diff --git a/test/fixture/main.tf b/test/fixture/main.tf index f2acfe36..62f07bf5 100644 --- a/test/fixture/main.tf +++ b/test/fixture/main.tf @@ -67,7 +67,8 @@ module "aks" { rbac_aad_managed = true sku_tier = "Paid" vnet_subnet_id = azurerm_subnet.test.id - + enable_maintenance_window = false + depends_on = [azurerm_resource_group.main] } diff --git a/variables.tf b/variables.tf index b8c9a9e0..df5e104a 100644 --- a/variables.tf +++ b/variables.tf @@ -449,4 +449,28 @@ variable "vnet_subnet_id" { type = string description = "(Optional) The ID of a Subnet where the Kubernetes Node Pool should exist. Changing this forces a new resource to be created." default = null +} + +variable "enable_maintenance_window" { + description = "Enable maintenance for AKS cluster" + type = bool + default = false +} + +variable "maintenance_allowed" { + description = "Days and hours when maintenance is allowed" + type = list(object({ + day = string + hours = list(number) + })) + default = [] +} + +variable "maintenance_not_allowed" { + description = "Days and hours when maintenance is not allowed" + type = list(object({ + end = string + start = string + })) + default = [] } \ No newline at end of file