Open terrymandin opened 6 months ago
also looking for this..
@favoretti any updates?
Any updates?
I guess it's not doable in Terraform yet! target_resource_id or resource_id to specify the VNET are not simply working in azurerm_network_watcher_flow_log. We seem to have to use NSG' for now...
@ryanghavidel2024 I just tried to set a VNet id to the "targetResourceId" field in their REST API endpoint to create flow logs and successfully created VNet Flow Logs. Since Azure Go SDK supports sending this field, it should work. API definition: https://learn.microsoft.com/en-us/rest/api/network-watcher/flow-logs/create-or-update?view=rest-network-watcher-2024-01-01
it also works with azapi
provider
resource "azapi_resource" "vnet_flow_logs" {
type = "Microsoft.Network/networkWatchers/flowLogs@2023-11-01"
name = "${azurerm_virtual_network.this.name}-logs"
location = data.azurerm_network_watcher.this.location
parent_id = data.azurerm_network_watcher.this.id
tags = var.tags
body = jsonencode({
properties = {
enabled = true
flowAnalyticsConfiguration = {
networkWatcherFlowAnalyticsConfiguration = {
enabled = false
}
}
format = {
type = "JSON"
version = 2
}
retentionPolicy = {
days = 7
enabled = true
}
storageId = azurerm_storage_account.flow_logs.id
targetResourceId = azurerm_virtual_network.this.id
}
})
}
@kaplik @MrImpossibru Super! Thanks so much.
Looks like NSG targeted flow logs have a deprecation announcement, luckily it's not till June 2025 (2027 for EOL) but it's now official that VNET Flow Logs will be the go forward: https://learn.microsoft.com/en-us/azure/network-watcher/nsg-flow-logs-overview
Hi there,
Please update this issue has been open since May... ???
Thanks @kaplik for the workarround ;)
But it's better to have this basic feature in azurerm provider especially since the announcement of the nsgflowlogs deprecation.
Fortunately yes we have a little time @jhutchings , but it's going to happen very quickly.
Any updates regarding the timeline?
Looks like NSG targeted flow logs have a deprecation announcement, luckily it's not till June 2025 (2027 for EOL) but it's now official that VNET Flow Logs will be the go forward: https://learn.microsoft.com/en-us/azure/network-watcher/nsg-flow-logs-overview
A bit off-topic, but this was about time. Having to create a NSG flow log to have traces from network activity on a subnet level is a weird approach.
are we sure this was resolved? I'm pointing to v4.10.0 and am still seeing that "network_security_group_id" is a required parameter, and "target_resource_id" is not recognized as a valid parameter.
are we sure this was resolved? I'm pointing to v4.10.0 and am still seeing that "network_security_group_id" is a required parameter, and "target_resource_id" is not recognized as a valid parameter.
They still need to release a newer version with this change.
Is there an existing issue for this?
Community Note
Description
I am creating a Terraform Azure Verified Module for Flow Logs. We have a requirement to create a flow log as part of the VNet creation. This is supported in the portal:
but not in the provider. Please add this capability.
I believe that the network_security_group_id variable should be renamed to target_resource_id similar to azapi. I confirmed that setting this to a VNet also works. It doesn't have to be just a NSG.
New or Affected Resource(s)/Data Source(s)
azurerm_network_watcher_flow_log
Potential Terraform Configuration
References
No response