I am getting a role definition in terraform from azure with the following command:
data "azurerm_role_definition" "test_role" {
name = "Test Role"
scope = data.azurerm_subscription.test-subscription.id
}
With the id of the role I am trying to create a role assignment with terraform:
resource "azuread_app_role_assignment" "test_assignment" {
app_role_id = data.azurerm_role_definition.test_role.id
...
}
But when I run terraform plan I am getting the error:
Error: Value must be a valid UUID
I also tried:
resource "azuread_app_role_assignment" "test_assignment" {
app_role_id = data.azurerm_role_definition.test_role.role_definition_id
...
}
This gave me the same error message.
Do you have any idea how to get the UUID of a role in terraform?
2
Answers
As discussed in the comments:
You mixed up the different role assignments. What you are looking for is the RBAC assignment azurerm_role_assignment
I tried below code and receieved same error:
Error:
Here resource_object_id must be service principal object Id .
Service principal can be obtained from creating application in azure ad.
Or
When the system assigned identity is used, the id of the system managed identity must be used.
Azure ad role is different from azurerm role:
Try below code:
or
Also below code worked:
Reference :