-
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_pim_eligible_role_assignment attempts to recreate after circa 45 days - error "already exists" #25811
Comments
I did quite some troubleshooting around this issue yesterday which leads me to the conclusion that the information which is saved in the terraform state is based on the wrong Azure resource. The relevant code was already reference from @TeamDman in #23111 : terraform-provider-azurerm/internal/services/authorization/pim_eligible_role_assignment_resource.go Lines 284 to 304 in dcf3258
There are basically two Azure resources for PIM eligible role assignments:
If following the official documentation https://learn.microsoft.com/en-us/rest/api/authorization/privileged-role-eligibility-rest-sample it is also obvious that you can get existing assignments only through The problem seems to be now that the In the Terraform trace log it is also quite obvious why terraform loses track of the existing role assignment. It is basically also because
Then a second GET request is made for
So when the
But this should not happend as long as the actual So, in short the |
@manicminer Then this is probably also fixed with #25956 ? |
@manicminer thank you! Yes I (re)created this issue because #24118 was closed because the problem was supposedly solved. But it showed now that it was actually not. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Is there an existing issue for this?
Community Note
Terraform Version
1.8.2
AzureRM Provider Version
3.99.0
Affected Resource(s)/Data Source(s)
azurerm_pim_eligible_role_assignment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Terraform should not loose the existing PIM eligible role assignment from it state and should not try to recreate it despite the role assignment still exists in Azure. The state of Terraform must be always the as the state in Azure it self.
Actual Behaviour
After a period of time, circa 45 days Terraform removes the roles assignment form the TF state and therefore wants to recreate the role assignment. But the create fails then obviously because the role assignment is still there in Azure.
Steps to Reproduce
Important Factoids
No response
References
It was presumed it is fixed in: #24118 but it is actually not. The root cause seems to be still exist.
#23111 seems to have the same root cause. Which make importing a an existing
azurerm_pim_eligible_role_assignment
resource impossible which makes this issue even more annoying. Because normally such errors could be fixed with aterraform import
but this is not possibile in this case because Terraform thinks the ressource does no exist in Azure (wich is not true and a bug in the azurerm provider).The text was updated successfully, but these errors were encountered: