Introduction
This article provides guidance for resolving an error encountered during the Terraform plan phase related to azurerm_kubernetes_cluster_node_pool
resource configurations. The issue is tied to a mismatch in attribute naming between different versions of the Terraform AzureRM provider, where the recent state was provisioned with azurerm 3.x and the attempted Terraform operations was configured with azurerm 4.x.
Problem
Terraform fails during the plan
phase when decoding state for the azurerm_kubernetes_cluster_node_pool
resource due to an unsupported argument.
Error: Failed to decode resource from state
Error decoding "module.aks.azurerm_kubernetes_cluster_node_pool.builder[0]" from previous state: unsupported attribute "auto_scaling_enabled"
Failed generating plan JSON
Failed to marshal plan to json: error marshaling prior state: unsupported attribute "auto_scaling_enabled"
Prerequisites
-
AzureRM Terraform Provider major versions 3.x and 4.x
-
Terraform configurations using the
azurerm_kubernetes_cluster_node_pool
resource -
Environments where Terraform state has been generated using a different major version of the provider than is currently being used
- Configurations where the azurerm provider current attempted version is 4.x and the recent state apply was 3.x
Cause
- This error is caused by a change in argument naming between versions of the AzureRM provider, specifically in the
azurerm_kubernetes_cluster_node_pool
resource. - In AzureRM 3.x, the attribute was
enable_auto_scaling = true
- In AzureRM 4.x this attribute was renamed to
auto_scaling_enabled = true
- When Terraform attempts to run a plan using AzureRM v4.x, but the existing Terraform state file still references the older attribute (
enable_auto_scaling
from v3.x), Terraform is unable to decode the resource from state because that attribute no longer exists in the newer provider schema. -
This results in a decoding error like the one below:
- Despite what the error says, the issue is that Terraform is expecting
auto_scaling_enabled
(v4.x), but the state containsenable_auto_scaling
(v3.x) — a mismatch that Terraform cannot reconcile during planning.
Solutions:
- Update your provider block to use AzureRM version 4.x or higher, an example is below:
Outcome
After completing the steps above, rerun terraform plan
. If the mismatch between state and configuration is resolved, the plan should succeed without decoding errors.
If you continue to see decoding issues, verify that no outdated modules or provider blocks are referencing the old attribute name.