Search code examples
azureterraformuuidroles

Azure cannot get UUID from role in terraform


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?


Solution

  • As discussed in the comments:

    You mixed up the different role assignments. What you are looking for is the RBAC assignment azurerm_role_assignment