Skip to content

Commit 8cc4df4

Browse files
azurerm_network_watcher_flow_log - add nil check for traffic_analytics (#28416)
1 parent e9ebf4e commit 8cc4df4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

internal/services/network/network_watcher_flow_log_resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ func flattenNetworkWatcherFlowLogTrafficAnalytics(input *flowlogs.TrafficAnalyti
559559
func expandNetworkWatcherFlowLogTrafficAnalytics(d *pluginsdk.ResourceData) *flowlogs.TrafficAnalyticsProperties {
560560
vs := d.Get("traffic_analytics").([]interface{})
561561

562+
if len(vs) == 0 {
563+
return nil
564+
}
565+
562566
v := vs[0].(map[string]interface{})
563567
enabled := v["enabled"].(bool)
564568
workspaceID := v["workspace_id"].(string)

internal/services/network/network_watcher_flow_log_resource_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ func testAccNetworkWatcherFlowLog_trafficAnalytics(t *testing.T) {
218218
check.That(data.ResourceName).ExistsInAzure(r),
219219
),
220220
},
221+
{
222+
Config: r.basicConfig(data),
223+
Check: acceptance.ComposeTestCheckFunc(
224+
check.That(data.ResourceName).ExistsInAzure(r),
225+
),
226+
},
227+
data.ImportStep(),
221228
})
222229
}
223230

0 commit comments

Comments
 (0)