Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance window support #133

Closed
wants to merge 9 commits into from
Closed
18 changes: 18 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ resource "azurerm_kubernetes_cluster" "main" {
}
}

maintenance_window {
dynamic "allowed" {
for_each = var.enable_maintenance_window == true ? var.maintenance_allowed : []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the following expression be better?

for_each = var.enable_maintenance_window ? var.maintenance_allowed : []

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

content {
day = allowed.value.day
hours = allowed.value.hours
}
}

dynamic "not_allowed" {
for_each = var.enable_maintenance_window == true ? var.maintenance_not_allowed : []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this line too:

for_each = var.enable_maintenance_window ? var.maintenance_not_allowed : []

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

content {
start = not_allowed.value.start
end = not_allowed.value.end
}
}
}

addon_profile {
http_application_routing {
enabled = var.enable_http_application_routing
Expand Down
1 change: 1 addition & 0 deletions test/fixture/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module "aks" {
sku_tier = "Paid"
private_cluster_enabled = true
enable_auto_scaling = true
enable_maintenance_window = false
agents_min_count = 1
agents_max_count = 2
agents_count = null
Expand Down
24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,27 @@ variable "enable_host_encryption" {
type = bool
default = false
}

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(string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the hours is number (doc), would the type list(number) be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}))
default = []
}

variable "maintenance_not_allowed" {
description = "Days and hours when maintenance is not allowed"
type = list(object({
end = string
start = string
}))
default = []
}