Terraform rejects addon_profile in azurerm_kubernetes_cluster
Fix it fast
Most common cause, 1 of 3addon_profile was removed in azurerm 3.0
Delete the addon_profile wrapper and the old enabled flags.
resource "azurerm_kubernetes_cluster" "aks" {
# ...name, location, default_node_pool, identity...
azure_policy_enabled = true
oms_agent {
log_analytics_workspace_id = azurerm_log_analytics_workspace.main.id
}
key_vault_secrets_provider {
secret_rotation_enabled = true
}
}Short answer
Error: Unsupported block type in azurerm_kubernetes_cluster means your config uses a block that the installed azurerm provider no longer has. addon_profile and role_based_access_control were removed in 3.0, and 4.0 renamed node pool arguments such as enable_auto_scaling. Move each setting to its current top-level form and pin the provider version. Applies to azurerm 4.x and 5.14.
Which cause do you have?
Check which azurerm release Terraform actually installed. A config written for 2.x meets a 3.x or newer provider in causes 1 and 2; a 3.x config on a 4.x or 5.x provider gives the renamed-argument errors of cause 3.
terraform version
grep -n -A3 "azurerm" versions.tf main.tfThen find the line you see in this list and open its fix:
- 1addon_profile was removed in azurerm 3.0
The message names addon_profile, and the block wraps oms_agent, azure_policy or azure_keyvault_secrets_provider - 2role_based_access_control was split into an argument and a new block
The message names role_based_access_control, usually with an azure_active_directory block nested inside it - 3A 4.0 rename hits the node pool and API server settings
The error is Unsupported argument for enable_auto_scaling, enable_node_public_ip, enable_host_encryption or api_server_authorized_ip_ranges
What does the error look like?
Error: Unsupported block typeBlocks of type "addon_profile" are not expected here.Blocks of type "role_based_access_control" are not expected here.An argument named "enable_auto_scaling" is not expected here.
Cause 1 of 3
addon_profile was removed in azurerm 3.0
You seeThe message names addon_profile, and the block wraps oms_agent, azure_policy or azure_keyvault_secrets_provider
Check
Unsupported block type for addon_profile appears because the azurerm 3.0 upgrade guide removed that wrapper block and moved every add-on to the top level of the cluster resource. azure_policy became the azure_policy_enabled boolean, oms_agent and key_vault_secrets_provider became top-level blocks, and kube_dashboard was dropped entirely.
grep -n -A12 "addon_profile" *.tfFix
Delete the addon_profile wrapper and the old enabled flags. An add-on block is now switched on by being present. kube_dashboard has no replacement and simply goes.
resource "azurerm_kubernetes_cluster" "aks" {
# ...name, location, default_node_pool, identity...
azure_policy_enabled = true
oms_agent {
log_analytics_workspace_id = azurerm_log_analytics_workspace.main.id
}
key_vault_secrets_provider {
secret_rotation_enabled = true
}
}Verify
terraform validate passes, and terraform plan shows no change for add-ons that were already on.
terraform validate && terraform planConfirmed by raw.githubusercontent.com
Cause 2 of 3
role_based_access_control was split into an argument and a new block
You seeThe message names role_based_access_control, usually with an azure_active_directory block nested inside it
Check
The same 3.0 guide removed the role_based_access_control block in favour of the role_based_access_control_enabled argument and a separate azure_active_directory_role_based_access_control block. A config that still nests Azure AD settings inside the old block fails with Unsupported block type.
grep -n -A8 "role_based_access_control" *.tfFix
Replace the old block with the argument and the new block. Azure AD admin groups go in admin_group_object_ids, and azure_rbac_enabled switches on role-based access control based on Azure AD.
role_based_access_control_enabled = true
azure_active_directory_role_based_access_control {
admin_group_object_ids = [var.aks_admin_group_id]
azure_rbac_enabled = true
}Verify
terraform plan shows no replacement of the cluster. The provider docs note that changing role_based_access_control_enabled forces a new cluster, so stop if plan wants to replace it.
terraform planConfirmed by raw.githubusercontent.com
Cause 3 of 3
A 4.0 rename hits the node pool and API server settings
You seeThe error is Unsupported argument for enable_auto_scaling, enable_node_public_ip, enable_host_encryption or api_server_authorized_ip_ranges
Check
Configs written for 3.x break on 4.0 and later because the 4.0 guide renamed default_node_pool.enable_auto_scaling to auto_scaling_enabled, enable_node_public_ip to node_public_ip_enabled and enable_host_encryption to host_encryption_enabled. It also removed api_server_authorized_ip_ranges in favour of api_server_access_profile.authorized_ip_ranges.
grep -nE "enable_auto_scaling|enable_node_public_ip|enable_host_encryption|api_server_authorized_ip_ranges" *.tfFix
Rename the arguments and move the IP list into the api_server_access_profile block.
default_node_pool {
name = "system"
vm_size = "Standard_D4s_v5"
auto_scaling_enabled = true
min_count = 1
max_count = 3
}
api_server_access_profile {
authorized_ip_ranges = ["203.0.113.0/24"]
}Verify
terraform validate finishes without the Unsupported argument errors, and plan shows the node pool unchanged.
terraform validateConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Pin azurerm with a ~> constraint such as ~> 5.14 in required_providers, and move to a new major only with its upgrade guide open.
- Commit .terraform.lock.hcl so every machine and CI job installs the same provider build.
- Make terraform validate a required pull-request check, so a removed block is caught in review rather than during apply.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro.