Closed AgueroPefai closed 2 years ago
@AgueroPefai As you are using the provider prior to v2.96.0, you'll need to import the flow log via following format:
terraform import azurerm_network_watcher_flow_log.watcher1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkWatchers/watcher1/networkSecurityGroupId/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkSecurityGroups/group1
While this way has issue when you have a long name.
Alternatively, you can upgrade your provider version to v2.96.0 or later, then you can import the resource in form of:
terraform import azurerm_network_watcher_flow_log.watcher1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/networkWatchers/watcher1/flowLogs/log1
Got it!. Let me try it out!
Closing since out since we've not heard back here - if this is still AN ISSUE then please let us know and we can take another look.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform (and AzureRM Provider) Version
Terraform v1.1.7 on darwin_amd64
Affected Resource(s)
azurerm_network_watcher_flow_log
Terraform Configuration Files
resource "azurerm_network_watcher_flow_log" "test" {
network_watcher_name = "NetworkWatcher_canadacentral" resource_group_name = "NetworkWatcherRG"
network_security_group_id = azurerm_network_security_group.nsg.id storage_account_id = azurerm_storage_account.storageaccount["OTHER"].id enabled = true
retention_policy { enabled = true days = 90 }
traffic_analytics { enabled = true workspace_id = azurerm_log_analytics_workspace.law.workspace_id workspace_region = azurerm_log_analytics_workspace.law.location workspace_resource_id = azurerm_log_analytics_workspace.law.id interval_in_minutes = 10 } }
Debug Output
N/A
Panic Output
N/A
Expected Behaviour
The resource should have been imported.
Actual Behaviour
terraform import azurerm_network_watcher_flow_log.test $flowlog.id
azurerm_network_watcher_flow_log.anw_flg_v2_cmn_alt: Importing from ID "/subscriptions/xxxxxxxxx/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkWatchers/NetworkWatcher_canadacentral/flowLogs/verylargenameofnsg"... ╷ │ Error: parsing Resource ID "/subscriptions/xxxxxxxxxxxx/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkWatchers/NetworkWatcher_canadacentral/flowLogs/verylargenameofnsg": Error: Network Watcher Flow Log ID could not be split on
/networkSecurityGroupId
: /subscriptions/xxxxxxxx/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkWatchers/NetworkWatcher_canadacentral/flowLogs/verylargenameofnsgSteps to Reproduce
Important Factoids
N/A
References
N/A