Open hriaz opened 3 years ago
hi @hriaz you probably need to create your own network watchers as per the following examples: https://github.com/aztfmod/terraform-azurerm-caf/tree/master/examples/networking/virtual_network/202-nsg-flow-logs-v2
@hriaz did you manage to resolve this issue? I've just hit the same thing when trying to enable network watcher & NSG flow logs
I think the issue might be with the way workspace_region gets populated from resource_location.
In our case, we want to use a central UK South Log Analytics Workspace, but have the resources (Network Watcher & NSG) we are applying this to, exist in UK West.
Therefore the workspace_region is actually different to the value getting set at resource_location
dynamic "traffic_analytics" {
for_each = try(var.settings.traffic_analytics, {}) != {} ? [1] : []
content {
enabled = var.settings.traffic_analytics.enabled
interval_in_minutes = try(var.settings.traffic_analytics.interval_in_minutes, null)
workspace_id = var.diagnostics.log_analytics[var.diagnostics.diagnostics_destinations.log_analytics[var.settings.traffic_analytics.log_analytics_workspace_destination].log_analytics_key].workspace_id
workspace_region = var.resource_location
workspace_resource_id = var.diagnostics.log_analytics[var.diagnostics.diagnostics_destinations.log_analytics[var.settings.traffic_analytics.log_analytics_workspace_destination].log_analytics_key].id
}
If log analytics workspaces are created in a different region vs the network watcher, you receive an error that the region is invalid. However, you are able to manually set this via the Azure portal.
Error: Error creating "Flow Log: (Name \"Microsoft.Networkrg-samplenet-002snet-use2-prod-002\" / Network Watcher Name \"NetworkWatcher_eastus2\" / Resource Group \"NetworkWatcherRG\")": network.FlowLogsClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InvalidTAWorkspaceRegion" Message="The specified region eastus2 for workspace is invalid. Workspace /subscriptions/xxxxxxxxxxx/resourceGroups/rg-global-launchpad-operations/providers/Microsoft.OperationalInsights/workspaces/log-emea-launchpad-euno located in northeurope region." Details=[]