Skip to content

Setting automatic_channel_upgrade to "patch" leads to Terraform state drift #335

@zioproto

Description

@zioproto

Is there an existing issue for this?

  • I have searched the existing issues

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.4.2

Module Version

6.7.1

AzureRM Provider Version

v3.49.0

Affected Resource(s)/Data Source(s)

azurerm_kubernetes_cluster

Terraform Configuration Files

module "aks" {
  source                           = "Azure/aks/azurerm"
  version                          = "6.7.1"
  kubernetes_version               = "1.25"
  orchestrator_version             = null
  automatic_channel_upgrade        = "patch"
[..CUT..]
}

tfvars variables values

none

Debug Output/Panic Output

~ resource "azurerm_kubernetes_cluster" "main" {
id = "{REDACTED}"
~ kubernetes_version = "1.25.6" -> "1.25"

Expected Behaviour

Terraform should not have state drift when an automatic upgrade happens in the patch channel.

Actual Behaviour

When creating the cluster the AKS API returns this values:

 az aks show --name istio-aks -g istio-aks -o json | jq ".kubernetesVersion, .currentKubernetesVersion"
"1.25"
"1.25.5"

After an automatic upgrade ( automatic_channel_upgrade=patch ) the AKS API will return something like:

 az aks show --name istio-aks -g istio-aks -o json | jq ".kubernetesVersion, .currentKubernetesVersion"
"1.25.6"
"1.25.6"

Because Terraform saved in the state:

   "kubernetes_version": "1.25",

This will cause a Terraform state drift at the next terraform apply operation.

Steps to Reproduce

terraform apply with this minimal config:

module "aks" {
  source                           = "Azure/aks/azurerm"
  version                          = "6.7.1"
  kubernetes_version               = "1.25"
  orchestrator_version             = null
  automatic_channel_upgrade        = "patch"
[..CUT..]
}

Wait for an automatic upgrade to happen and run again terraform apply

Important Factoids

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions