-
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
RoleAssignmentNotFound with azurerm_role_assignment #9379
Comments
I added a dependency between the tc role assignments and tc, and the error still occurs. Its almost like the number of role assignments created consecutively causes the issue. |
Chaining the dependencies didn't resolve the RoleAssignmentNotFound. It did however limit the failure to 1 role assignment rather than 3. My next attempt is to create a role definition from the built in roles and see if that has a higher success rate. |
I switched to a pre-configured role definition, and the same problem occurs.
|
This is also an issue for me as well. We're using role assignments the same way on a Keyvault and the state isn't making it to the state file after the first run, causing an error until the resource is imported. |
We have a trace of what is going on:
|
We've hit this as well. We run our TF deployment pipelines on-prem and in Azure DevOps. The bug hits us only in pipelines running on ADO. I've been unable to reproduce it locally but just ran my test case on an ADO agent node and was able to reproduce on the first try. My suspicion is that running TF in close proximity to the Azure API results in much quicker API response times, and the provider hits a race condition here. The initial create request returns but the operation is not atomic and a quick Get on the resource 404s, causing the provider to bail. I believe wrapping the second request in a retry will fix the issue. I'm in the process of testing now. Test case:
Create a bunch of role assignments for MSI on resources:
|
I have submitted a fix for this here #9698 |
@dlamotte Tested the fix locally and it solves the issue for me. Thanks much. |
This has been released in version 2.43.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.43.0"
}
# ... other configuration ... |
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. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.13.3
Affected Resource(s)
azurerm_role_assigment
Terraform Configuration Files
Debug Output
Expected Behaviour
Success
Actual Behaviour
Failure
Important Factoids
Before I placed the dependency between the VMSS and role assignments, the failure between tc role assignment would occur on the tc VMSS. Once the dependency was added it shifted to the te VMSS.
Not all role assignments fail, its usually 2 or 3, guess its timing related.
The text was updated successfully, but these errors were encountered: