We have a Azure Subscription which is created in default management group (Root Tenant Group). I am trying to read the information of this subscrption and managment group using "data "azurerm_management_group" "xx" "" But i am getting an unautorized error reading Management Group (Display Name "Tenant Root Group"): listing Management Groups: managementgroups.Client#List: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" ""
I have a Security Reader access on the managment group and only owner is above me.
Is there a way to troubleshoot this?
PS: For a module dependency limitation i using an older version of azurerm which is v2.95.0.
expecting a managment group id to be read using terraform code
Expecting a managment group id to be read using terraform code.
To retrieve information about the Parent Management Group
using Terraform, the Global Administrator
role is required, not the Security Reader role
. The Security Reader
role is intended for accessing information about Child Groups
, not Parent Group
information. Refer to the Microsoft Documentation for more details
Note: If you are a Global Administrator in Azure AD, you can assign yourself access to all Azure subscriptions and management groups in your directory.
Terraform code:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.95.0"
}
}
}
provider "azurerm" {
features {}
skip_provider_registration ="true"
}
data "azurerm_management_group" "example" {
display_name = "Tenant Root Group"
}
output "display_name" {
value = data.azurerm_management_group.example.display_name
}
Terraform Apply