Hi, I am trying to configure a transformation on AppServiceHTTPLogs.
The problem is the azurerm_log_analytics_workspace resource references the azurerm_monitor_data_collection_rule and vice versa. If I use azurerm_monitor_data_collection_rule.inte_dcr.id for the data_collection_rule_id in azurerm_log_analytics_workspace I have a Cycle error and so I am compelled to write the id “manually” (see code below, commented line in azurerm_log_analytics_workspace is the one working).
Is there a better way to implement this in terraform or am I missing something ?
resource "azurerm_log_analytics_workspace" "log" {
provider = azurerm.sub-lz-dev
name = "log-weu-inte-oncrawl"
resource_group_name = azurerm_resource_group.inte_rg.name
location = azurerm_resource_group.inte_rg.location
sku = "PerGB2018"
retention_in_days = 30
tags = azurerm_resource_group.inte_rg.tags
data_collection_rule_id = azurerm_monitor_data_collection_rule.inte_dcr.id
#data_collection_rule_id = "/subscriptions/${var.v_global_provider_sub_id}/resourceGroups/${azurerm_resource_group.inte_rg.name}/providers/Microsoft.Insights/dataCollectionRules/${local.data_collection_rules_name}"
}
resource "azurerm_monitor_data_collection_rule" "inte_dcr" {
provider = azurerm.sub-lz-dev
name = local.data_collection_rules_name
resource_group_name = azurerm_resource_group.inte_rg.name
location = azurerm_resource_group.inte_rg.location
tags = azurerm_resource_group.inte_rg.tags
kind = "WorkspaceTransforms"
destinations {
log_analytics {
workspace_resource_id = azurerm_log_analytics_workspace.log.id
name = azurerm_log_analytics_workspace.log.name
}
}
data_flow {
streams = ["Microsoft-Table-AppServiceHTTPLogs"]
destinations = [azurerm_log_analytics_workspace.log.name]
transform_kql = "source| where UserAgent contains \"Googlebot\""
}
identity {
type = "SystemAssigned"
}
}
Thanks!
E.