azurerm_role_definition
- Create a custom role definition ‘xyz_custom_01’ via terraform using resource block of azurerm_role_definition
- Use data block as below to retrieve the output of custom role Definition deployed in Step1
data "azurerm_role_definition" "all_role_definitions2" {
name = "xyz_custom_01"
# scope = data.azurerm_subscription.primary.id
provider = azurerm.Subscription
}
Tried using with and without scope parameter. I get error as-
Error: Error loading Role Definition List: could not find role 'xyz_custom_01'
on MAIN_01_IAM.tf line 10, in data "azurerm_role_definition" "all_role_definitions2":
10: data "azurerm_role_definition" "all_role_definitions2" {
But the same when I used role_definition_id and fetched the name of custom role definition, it worked. Looks like a bug in data source.
Says this ain’t a Terraform bug…! Refer Data Source for custom role definition using azurerm_role_definition is not working · Issue #12236 · terraform-providers/terraform-provider-azurerm · GitHub