-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_role_assignment
- Normalize case of the scope
property
#26086
base: main
Are you sure you want to change the base?
Conversation
azurerm_role_assignment
- Normalize case of the scope
property during readsazurerm_role_assignment
- Normalize case of the scope
property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rifelpet - Thanks for this PR. Unfortunately I think this is the wrong way to fix this, CaseDifference
frequently results in bugs of other flavours in resource IDs. The normalizeScopeValue
func I think should be extended to support all potential ID types (as defined in the Validation function) and provide the correct returned value accordingly. Could you take a look at this?
@jackofallops I can extend Does |
Quick ping on this @jackofallops any thoughts on how to proceed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rifelpet, apologies for the delay on getting this looked at again. From my understanding of this problem, it looks to be a direct result of what @jackofallops was alluding to in his review that having a resource group id with inconsistent casing results in down stream resources wanting to be recreated.
From the plan you've shown, we have a resource group id with the correct casing in state but the config file has a resource group id with the incorrect casing which is causing Terraform to want to recreate the resource.
I think instead of adding suppress.CaseDifference, we need to figure out where the inconsistent casing is coming from. Do you mind sharing your config file or where the resource group id is coming from so we can try and fix the casing there?
Hi @mbfrahry Here is my terraform configuration. It is in a shared module where only some of the root modules exhibit the behavior reported here, others have a no-op plan as expected. All of the actual role assignments in azure were created from this shared module over the past few years. resource "azurerm_role_assignment" "foo" {
scope = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourcegroups/${var.resource_group_name}"
role_definition_id = azurerm_role_definition.foo.role_definition_resource_id
principal_id = azurerm_user_assigned_identity.foo.principal_id
} Changing the casing from
The Azure documentation mentions that resource group names are case insensitive, leading me to also believe that there is no "correct casing" which is why the provider should also treat it as case insensitive. There are many similar reports in #21085, perhaps this can be fixed for all resources that accept a |
@rifelpet - while azure will generally treat inputs as insensitive there still is a "correct" or "true" casing for each resource ID as well as standards for what the casing of each resource ID segment should be. the |
Community Note
Description
This relates to #20138
The azurerm_role_assignment resource can be incorrectly replaced because of a casing change in the scope field:
Notice that the old scope contained
resourceGroups
and the new scope containsresourcegroups
. I confirmed that removing and reimporting the resource in the terraform state does not fix the issue. Instead we add a DiffSuppressFunc on scope to match other fields on this resource.PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
The following tests passed. I dont have access to an environment with the necessary permissions to run the remaining acceptance tests.
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_role_assignment
- normalize case of thescope
property during reads [azurerm_role_assignment
- Normalize case of thescope
property #26086]This is a (please select all that apply):
Related Issue(s)
This relates to #20138
Note
If this PR changes meaningfully during the course of review please update the title and description as required.