Azure RBAC roles can be assigned to users, groups, or service principals. A role assignment grants permissions on a predefined set of resources called "scope".
The widest scopes a role can be assigned to are:
In case of security incidents involving a compromised identity (user, group, or service principal), limiting its role assignment to the narrowest scope possible helps separate duties and limits what resources are at risk.
There is a risk if you answered yes to any of these questions.
resource "azurerm_role_assignment" "example" {
scope = data.azurerm_subscription.primary.id # Sensitive
role_definition_name = "Reader"
principal_id = data.azuread_user.user.object_id
}
resource "azurerm_role_assignment" "example" {
scope = azurerm_resource_group.example.id
role_definition_name = "Reader"
principal_id = data.azuread_user.user.object_id
}