terraform-provider-azurerm: Data Source for custom role definition using azurerm_role_definition is not working
Terraform (and AzureRM Provider) Version
Azure RM 2.63.0
Affected Resource(s)
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.
Attention: @tombuildsstuff @aristosvo @favoretti
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (2 by maintainers)
Also from what I see from the block that you shared above - this will try to create multiple roles in the same subscription, since for_each loop will go over the data with a single provider definition. Unfortunately there’s no real way to use for_each and switch provider config at the same time.