Within the past week azurerm_kubernetes_cluster started throwing and error with no code changes. We are using User Assigned Identities for our AKS cluster. The code in question is below and the resulting error. Any thoughts on what changed or how to troubleshoot the source of the issue?
# Create User Assigned Identity for the AKS Cluster
resource "azurerm_user_assigned_identity" "aks_id" {
name = "aks-${var.suffix}-${var.tags.environment}"
resource_group_name = data.azurerm_resource_group.aks_rg.name
location = data.azurerm_resource_group.aks_rg.location
}
# Assign "Network Contributor rol on the resource group containing the subnet where the aks cluster will be deployed
resource "azurerm_role_assignment" "aks_role" {
scope = data.azurerm_resource_group.aks_vnet.id
role_definition_name = "Network Contributor"
principal_id = azurerm_user_assigned_identity.aks_id.principal_id
}
# Create AKS Cluster
resource "azurerm_kubernetes_cluster" "main" {
......
identity {
type = "UserAssigned"
user_assigned_identity_id = azurerm_user_assigned_identity.aks_id.id
}
}
# Create User Assigned Identity for the AKS Cluster
resource "azurerm_user_assigned_identity" "aks_id" {
name = "aks-${var.suffix}-${var.tags.environment}"
resource_group_name = data.azurerm_resource_group.aks_rg.name
location = data.azurerm_resource_group.aks_rg.location
}
Error: updating Managed Kubernetes Cluster "bokf-4321-dev-eastus-aks-enterprise" (Resource Group "bokf-4321-dev-eastus-rg-enterprise-aks"): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidIdentityValues" Message="Invalid value for the identities '/subscriptions/xxxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx-4321-dev-eastus-rg-enterprise-aks/providers/Microsoft.ManagedIdentity/userAssignedIdentities/aks-enterprise-dev'. The 'UserAssignedIdentities' property keys should only be empty json objects, null or the resource exisiting property."
on .terraform/modules/aks/modules/compute/aks/aks_module.tf line 86, in resource "azurerm_kubernetes_cluster" "main":
86: resource "azurerm_kubernetes_cluster" "main" {
I can delete the AKS cluster and recreate it from scratch without error. If I then try to make no changes to the terraform code and simply run another apply. I get the same error. The only way to get past this error is to delete the AKS cluster and recreate any time I run an apply regardless of any or no changes to the code. Please advise.
Error: updating Managed Kubernetes Cluster âaks-cluster-nameâ (Resource Group âresourcegroup_xxxxâ): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=0 â Original Error: Code=âInvalidIdentityValuesâ
Message=âInvalid value for the identities â/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/resourcegroup_xxxx/providers/Microsoft.ManagedIdentity/userAssignedIdentities/aks_user_identity_xxxxâ.
The âUserAssignedIdentitiesâ property keys should only be empty json objects, null or the resource exisiting property.â
We also just encountered this problem. We use a user assigned managed identity that has the âNetwork Contributorâ role on our Vnet for our K8s cluster. Creating and recreating the cluster works fine, but when we try to make changes to an exisiting cluster (e.g. increase node count), we also get this error message:
Error: updating Managed Kubernetes Cluster âcluster-nameâ (Resource Group âresource-group-nameâ): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=0 â Original Error: Code=âInvalidIdentityValuesâ Message=âInvalid value for the identities â/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-assigned-identity-nameâ. The âUserAssignedIdentitiesâ property keys should only be empty json objects, null or the resource exisiting property.â
â Error: updating Managed Kubernetes Cluster "cluster" (Resource Group "grp"): containerservice.ManagedClustersClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidIdentityValues" Message="Invalid value for the identities '/subscriptions/nnn/resourcegroups/grp/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cluster_identity'. The 'UserAssignedIdentities' property keys should only be empty json objects, null or the resource exisiting property."
â
â with module.k8s_wrapper["cluster"].azurerm_kubernetes_cluster.k8s_cluster,
â on common/azure_k8s/k8s.tf line 34, in resource "azurerm_kubernetes_cluster" "k8s_cluster":
â 34: resource "azurerm_kubernetes_cluster" "k8s_cluster" {
â
â”
It seems that if I modify a cluster (ie pools size, version) it happens once, but goes away on a rerun. Is there some update to the state format that is vaguely incompatible here? Either in the AzureRM provider or terraform 1.0?