User Unable to Access Key Vault Secrets Despite Role Assignment in Terraform
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 07:49 AM
Hi All,
I'm encountering an issue where a user is unable to access secrets in an Azure Key Vault, even though the user has been assigned the necessary roles using Terraform. Specifically, the user gets the following error when trying to access the secrets:
"The operation is not allowed by RBAC. If role assignments were recently changed, please wait several minutes for role assignments to become effective."
This issue only happens for the user — the service principal has the correct permissions and can access the secrets just fine.
Terraform Code: Below is the relevant Terraform code I'm using to configure Azure resources:
Steps to Reproduce:
- Create a Key Vault using Terraform.
- Assign the Key Vault Administrator role to the service principal.
- Assign the Key Vault Secrets User role to the user.
- Log in as the user (not the service principal).
- Attempt to access secrets in the Key Vault.
- Get the error: "The operation is not allowed by RBAC."
Expected Behavior: The user should be able to access the secrets from the Key Vault once the Key Vault Secrets User role is assigned.
Actual Behavior: The user is unable to access the secrets and gets the error message: "The operation is not allowed by RBAC."
Troubleshooting:
- I have waited for several minutes for role assignments to propagate, but the issue persists.
- I have verified the role assignments in the Azure portal and confirmed that both the service principal and user are assigned the correct roles.
- The service principal can access the secrets, but the user cannot.
Questions:
- Is there something I'm missing in terms of role assignments for users to access Key Vault secrets?
- Do I need to apply role assignments at a different scope (e.g., subscription, resource group)?
- Should I be using a different role (other than Key Vault Secrets User) for my user to be able to access the secrets?
Any help or suggestions would be greatly appreciated!