Open gevial opened 2 years ago
I tried to manually change 'g' to capital in the state but it didn't help. Seems to me like scope
id gets normalised by Terraform upon execution.
Hi @gevial Thanks for opening the issue! I'm seeing the same issue when creating a role assignment on Azure Portal.
I've then tried below two options which can give the correct indicator resourceGroups
you may want to give a try:
By using Terraform/Azure CLI/REST API to create the role assignment, the resource group indicator is correct, which is resourceGroups
.
And to fix it in-place, you can use an update call with the expected scope (with the upper G
in resourceGroups
) with Azure CLI az role assignment update
or REST API PUT
request (can be found in the above link). A small note: in my test, it can update resourcegroup
to resourceGroup
, but not the reverse way.
I see the same behavior on the following objects all on v 3.13.0 of the azureRM provider (and Terraform v1.2.4)
For me v3.15.1 azurerm provider and terraform v1.2.4:
For: kubernetes_cluster_id = azurerm_kubernetes_cluster.aks-cluster.id
Would the fix here be similar to #16267 which fixed #16166?
Is there an existing issue for this?
Community Note
Terraform Version
v1.1.7
AzureRM Provider Version
3.0.2
Affected Resource(s)/Data Source(s)
azurerm_role_assignment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Expected no changes.
Actual Behaviour
Terraform tries to replace the imported role assignment. Doesn't matter if you import it with
resourcegroups
orresourceGroups
in the id, in the state it lands with all lower case. And later onterraform plan
will try to replace the assignment withresourceGroups
(capital G) in the id.Steps to Reproduce
terraform import azurerm_role_assignment.developers /subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.ContainerService/managedClusters/xxx/providers/Microsoft.Authorization/roleAssignments/xxx
OR the same import command but
resourcegroups
instead ofresourceGroups
in the id (notice letter G is different).Terraform plan will show re-create in both ways.
Important Factoids
No response
References
No response