hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Bug on the resource: azurerm_kubernetes_cluster, the argument automatic_channel_upgrade doesn't work has expected. #17618

Closed BriceLag closed 2 years ago

BriceLag commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.2.4

AzureRM Provider Version

3.13.0

Affected Resource(s)/Data Source(s)

azurerm_kubernetes_cluster

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      version = "= 3.13.0"
    }
    tls = {
      version = ">=3.0.0"
    }
  }
}

provider "azurerm" {
  subscription_id = "YOUR-SUB-ID"
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_kubernetes_cluster" "example" {
  name                      = "example-aks1"
  location                  = azurerm_resource_group.example.location
  resource_group_name       = azurerm_resource_group.example.name
  dns_prefix                = "exampleaks1"
  automatic_channel_upgrade = "none"
  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_D2_v2"
  }

  identity {
    type = "SystemAssigned"
  }

  tags = {
    Environment = "Test"
  }
}

Debug Output/Panic Output

2022-07-13T11:37:30.313+0200 [DEBUG] provider: using plugin: version=5
2022-07-13T11:37:30.313+0200 [DEBUG] provider.terraform-provider-azurerm_v3.13.0_x5: plugin address: address=/tmp/plugin1159798836 network=unix timestamp=2022-07-13T11:37:30.312+0200
2022-07-13T11:37:30.523+0200 [ERROR] vertex "azurerm_kubernetes_cluster.example" error: expected automatic_channel_upgrade to be one of [patch rapid stable node-image], got none
╷
│ Error: expected automatic_channel_upgrade to be one of [patch rapid stable node-image], got none
│
│   with azurerm_kubernetes_cluster.example,
│   on main.tf line 27, in resource "azurerm_kubernetes_cluster" "example":
│   27:   automatic_channel_upgrade = "none"

Expected Behaviour

azurerm_kubernetes_cluster.example will be created

Actual Behaviour

Error: expected automatic_channel_upgrade to be one of [patch rapid stable node-image], got none

Steps to Reproduce

No response

Important Factoids

No response

References

Hello team, Thank you for your job. Following the documentation: https://registry.terraform.io/providers/hashicorp/azurerm/3.0.0/docs/resources/kubernetes_cluster#automatic_channel_upgrade I was expecting that the value "none" can be set on the argument: automatic_channel_upgrade. But he can't. Other github issue about that problem here: https://github.com/hashicorp/terraform-provider-azurerm/issues/11030.

In other hand I've perform the action manually on my cluster following this documentation: https://docs.microsoft.com/en-us/azure/aks/auto-upgrade-cluster. I've set the auto-upgrade-channel of my cluster from "none", to "stable" and back to "none" whitout any problem. az aks show --resource-group example-resources --name example-aks1 | grep -i chann az aks update --resource-group example-resources --name example-aks1 --auto-upgrade-channel none Can you do something ? Best regards,

Brice

ms-henglu commented 2 years ago

Hi @BriceLag ,

From the document, https://registry.terraform.io/providers/hashicorp/azurerm/3.0.0/docs/resources/kubernetes_cluster#automatic_channel_upgrade

Omitting this field sets this value to none.

BriceLag commented 2 years ago

Hi @ms-henglu, Thank you for your answer. But how can I wrote a module, to let the user choose the value, or back to 'none' on that parameter with terraform ? Best regards,

Brice

ms-henglu commented 2 years ago

Hi @BriceLag ,

You can use value null, more information can be found here

BriceLag commented 2 years ago

Thank you @ms-henglu .

For people who search a solution, to implement it in a module, I propose that one:

variable "automatic_channel_upgrade" {
  type        = string
  description = "(Optional) The upgrade channel for this Kubernetes Cluster. Possible values are: null, 'patch', 'rapid', 'node-image' and 'stable'. Omitting this field sets this value to none. ⚠ Cluster Auto-Upgrade will update the Kubernetes Cluster (and its Node Pools) to the latest GA version of Kubernetes automatically"
  default     = null
  validation {
    condition     = (var.automatic_channel_upgrade == null ? true : contains(["patch", "rapid", "node-image", "stable"], var.automatic_channel_upgrade))
    error_message = "Must be: 'patch', 'rapid', 'node-image' and 'stable'. Default value: null."
  }
}

I hope that one day this argument can accept 'none', as in the Azure documentation. :-)

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.