Open rikunarhi-cloud2 opened 1 year ago
Just adding a code snippet for an azapi work around until this is resolved:
resource "azapi_resource" "management_group_diag_settings" {
name = join("-", [data.azurerm_management_group.this.name, "diag"])
parent_id = azurerm_management_group.this.id
type = "Microsoft.Insights/diagnosticSettings@2021-05-01-preview"
schema_validation_enabled = false // This is required otherwise gets stuck in a destroy/create loop https://github.com/Azure/terraform-provider-azapi/issues/655
location = "global"
body = {
properties = {
logs = [
{
category = "Administrative"
enabled = true
},
{
category = "Policy"
enabled = true
}
]
workspaceId = var.workspace_id
}
}
response_export_values = ["*"]
}
Is there an existing issue for this?
Community Note
Terraform Version
1.3.1
AzureRM Provider Version
3.52.0
Affected Resource(s)/Data Source(s)
azurerm_monitor_diagnostic_setting
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
You should be able to add Diagnostic settings for a Management group. This is possible to add with REST API https://learn.microsoft.com/en-us/rest/api/monitor/management-group-diagnostic-settings/create-or-update?tabs=HTTP
Actual Behaviour
Plan fails as there is no subscription in target_resource_id parameter.
Steps to Reproduce
Important Factoids
No response
References
No response