From 07aef578a2cd035ab37576c9481ad2b14f19d6ce Mon Sep 17 00:00:00 2001 From: Nathanael Liechti Date: Wed, 7 Dec 2022 16:47:25 +0100 Subject: [PATCH] feat: add var automatic_channel_upgrade Signed-off-by: Nathaanel Liechti --- README.md | 1 + main.tf | 3 ++- variables.tf | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e9d38e3..47b6aa23 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,7 @@ No modules. | [agents\_tags](#input\_agents\_tags) | (Optional) A mapping of tags to assign to the Node Pool. | `map(string)` | `{}` | no | | [agents\_type](#input\_agents\_type) | (Optional) The type of Node Pool which should be created. Possible values are AvailabilitySet and VirtualMachineScaleSets. Defaults to VirtualMachineScaleSets. | `string` | `"VirtualMachineScaleSets"` | no | | [api\_server\_authorized\_ip\_ranges](#input\_api\_server\_authorized\_ip\_ranges) | (Optional) The IP ranges to allow for incoming traffic to the server nodes. | `set(string)` | `null` | no | +| [automatic\_channel\_upgrade](#input\_automatic\_channel\_upgrade) | (Optional) The upgrade channel for this Kubernetes Cluster. Possible values are `patch`, `rapid`, `node-image` and `stable`. By default automatic-upgrades are turned off. See [the documentation](https://learn.microsoft.com/en-us/azure/aks/auto-upgrade-cluste) for more information | `string` | `null` | no | | [azure\_policy\_enabled](#input\_azure\_policy\_enabled) | Enable Azure Policy Addon. | `bool` | `false` | no | | [client\_id](#input\_client\_id) | (Optional) The Client ID (appId) for the Service Principal used for the AKS deployment | `string` | `""` | no | | [client\_secret](#input\_client\_secret) | (Optional) The Client Secret (password) for the Service Principal used for the AKS deployment | `string` | `""` | no | diff --git a/main.tf b/main.tf index 922d134a..d152a426 100644 --- a/main.tf +++ b/main.tf @@ -19,6 +19,7 @@ resource "azurerm_kubernetes_cluster" "main" { name = var.cluster_name == null ? "${var.prefix}-aks" : var.cluster_name resource_group_name = data.azurerm_resource_group.main.name api_server_authorized_ip_ranges = var.api_server_authorized_ip_ranges + automatic_channel_upgrade = var.automatic_channel_upgrade azure_policy_enabled = var.azure_policy_enabled disk_encryption_set_id = var.disk_encryption_set_id dns_prefix = var.prefix @@ -253,4 +254,4 @@ resource "azurerm_log_analytics_solution" "main" { product = "OMSGallery/ContainerInsights" publisher = "Microsoft" } -} \ No newline at end of file +} diff --git a/variables.tf b/variables.tf index e1377b3d..05812639 100644 --- a/variables.tf +++ b/variables.tf @@ -93,6 +93,20 @@ variable "api_server_authorized_ip_ranges" { default = null } +variable "automatic_channel_upgrade" { + type = string + default = null + description = "(Optional) The upgrade channel for this Kubernetes Cluster. Possible values are `patch`, `rapid`, `node-image` and `stable`. By default automatic-upgrades are turned off. See [the documentation](https://learn.microsoft.com/en-us/azure/aks/auto-upgrade-cluste) for more information" + validation { + condition = ( + var.automatic_channel_upgrade == null || ( + can(regex("(patch|rapid|stable|node-image)", var.automatic_channel_upgrade)) + ) + ) + error_message = "`automatic_channel_upgrade`'s possible values are `patch`, `stable`, `rapid` or `node-image`." + } +} + variable "azure_policy_enabled" { type = bool description = "Enable Azure Policy Addon." @@ -232,7 +246,6 @@ variable "log_analytics_solution_id" { type = string description = "(Optional) Existing azurerm_log_analytics_solution ID. Providing ID disables creation of azurerm_log_analytics_solution." default = null - nullable = true } variable "log_analytics_workspace" { @@ -242,7 +255,6 @@ variable "log_analytics_workspace" { }) description = "(Optional) Existing azurerm_log_analytics_workspace to attach azurerm_log_analytics_solution. Providing the config disables creation of azurerm_log_analytics_workspace." default = null - nullable = true } variable "log_analytics_workspace_enabled" { @@ -256,7 +268,6 @@ variable "log_analytics_workspace_resource_group_name" { type = string description = "(Optional) Resource group name to create azurerm_log_analytics_solution." default = null - nullable = true } variable "log_analytics_workspace_sku" { @@ -501,4 +512,4 @@ variable "workload_identity_enabled" { description = "Enable or Disable Workload Identity. Defaults to false." type = bool default = false -} \ No newline at end of file +}