Getting 403 error in Terraform while assigning RBAC in Azure

Harshit Z Kothari 40 Reputation points
2024-10-24T14:47:37.2933333+00:00

I have correct access (Owner) and able to assign RBAC through portal but not Terraform.

│ Error: authorization.RoleAssignmentsClient#Create: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client 'xxxxxx' with object id '7229' does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/write' over scope '/subscriptions/58146/resourceGroups/eus2-rg/providers/Microsoft.KeyVault/vaults/kv01/providers/Microsoft.Authorization/roleAssignments/67d' or the scope is invalid. If access was recently granted, please refresh your credentials."

Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
972 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Harshitha Eligeti 4,380 Reputation points Microsoft External Staff Moderator
    2024-11-04T20:03:34.7066667+00:00

    Hi @Harshit Z Kothari 

    Thank you for sharing your issue on Microsoft Q&A. 

    I Understand that you are getting a 403 error while assigning RBAC in Azure portal but not via Terraform even though you have owner role. 

    The error message indicates that the scope is either invalid or the client does not have the required permissions to perform the action. Since you mentioned that you have an owner role, you should be able to assign users under RBAC. so, double-check that it exists and that you have access to it. If possible, please share your Terraform code. 

    If the issue continues, provide more details about the error so we can troubleshoot further. 

    I hope this information is helpful. Please feel free to reach out if you have any further questions.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Best regards, 
    Harshitha Eligeti. 


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.