From f2b32b2af2d171179c9a18d793284affbd787a2d Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 19 Aug 2020 13:26:22 +0800 Subject: [PATCH 1/6] Update segment of network packet capture --- .../services/network/network_packet_capture_resource.go | 4 ++-- .../network/tests/network_packet_capture_resource_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/network/network_packet_capture_resource.go b/azurerm/internal/services/network/network_packet_capture_resource.go index 4447e9b24f7c..b1f885a7f53f 100644 --- a/azurerm/internal/services/network/network_packet_capture_resource.go +++ b/azurerm/internal/services/network/network_packet_capture_resource.go @@ -217,7 +217,7 @@ func resourceArmNetworkPacketCaptureRead(d *schema.ResourceData, meta interface{ resourceGroup := id.ResourceGroup watcherName := id.Path["networkWatchers"] - name := id.Path["NetworkPacketCaptures"] + name := id.Path["packetCaptures"] resp, err := client.Get(ctx, resourceGroup, watcherName, name) if err != nil { @@ -266,7 +266,7 @@ func resourceArmNetworkPacketCaptureDelete(d *schema.ResourceData, meta interfac resourceGroup := id.ResourceGroup watcherName := id.Path["networkWatchers"] - name := id.Path["NetworkPacketCaptures"] + name := id.Path["packetCaptures"] future, err := client.Delete(ctx, resourceGroup, watcherName, name) if err != nil { diff --git a/azurerm/internal/services/network/tests/network_packet_capture_resource_test.go b/azurerm/internal/services/network/tests/network_packet_capture_resource_test.go index 9a7b004467ef..79323bb48970 100644 --- a/azurerm/internal/services/network/tests/network_packet_capture_resource_test.go +++ b/azurerm/internal/services/network/tests/network_packet_capture_resource_test.go @@ -239,7 +239,7 @@ resource "azurerm_virtual_machine" "test" { resource "azurerm_virtual_machine_extension" "test" { name = "network-watcher" - virtual_machine_id = azurerm_virtual_machine.src.id + virtual_machine_id = azurerm_virtual_machine.test.id publisher = "Microsoft.Azure.NetworkWatcher" type = "NetworkWatcherAgentLinux" type_handler_version = "1.4" From 4d47527bef8547d24212f35b6f6ffde78eb6e09b Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 21 Aug 2020 12:26:35 +0800 Subject: [PATCH 2/6] Update code --- ...twork_packet_capture_migration_resource.go | 36 ++++++++ .../network_packet_capture_resource.go | 34 ++++--- .../network/parse/network_packet_capture.go | 34 +++++++ .../parse/network_packet_capture_test.go | 90 +++++++++++++++++++ 4 files changed, 175 insertions(+), 19 deletions(-) create mode 100644 azurerm/internal/services/network/network_packet_capture_migration_resource.go create mode 100644 azurerm/internal/services/network/parse/network_packet_capture.go create mode 100644 azurerm/internal/services/network/parse/network_packet_capture_test.go diff --git a/azurerm/internal/services/network/network_packet_capture_migration_resource.go b/azurerm/internal/services/network/network_packet_capture_migration_resource.go new file mode 100644 index 000000000000..79d1ecd3a726 --- /dev/null +++ b/azurerm/internal/services/network/network_packet_capture_migration_resource.go @@ -0,0 +1,36 @@ +package network + +import ( + "fmt" + "log" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/terraform" +) + +func ResourceNetworkPacketCaptureMigrateState(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { + switch v { + case 0: + log.Println("[INFO] Found AzureRM Network Packet Capture State v0; migrating to v1") + return resourceNetworkPacketCaptureStateV0toV1(is, meta) + default: + return is, fmt.Errorf("Unexpected schema version: %d", v) + } +} + +func resourceNetworkPacketCaptureStateV0toV1(is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { + if is.Empty() { + log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") + return is, nil + } + + log.Printf("[DEBUG] ARM Network Packet Capture before Migration: %#v", is.Attributes) + + newID := strings.Replace(is.Attributes["id"], "/NetworkPacketCaptures/", "/packetCaptures/", 1) + is.Attributes["id"] = newID + is.ID = newID + + log.Printf("[DEBUG] ARM Network Packet Capture Attributes after State Migration: %#v", is.Attributes) + + return is, nil +} diff --git a/azurerm/internal/services/network/network_packet_capture_resource.go b/azurerm/internal/services/network/network_packet_capture_resource.go index b1f885a7f53f..110affaa4275 100644 --- a/azurerm/internal/services/network/network_packet_capture_resource.go +++ b/azurerm/internal/services/network/network_packet_capture_resource.go @@ -13,6 +13,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/network/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -23,6 +24,9 @@ func resourceArmNetworkPacketCapture() *schema.Resource { Read: resourceArmNetworkPacketCaptureRead, Delete: resourceArmNetworkPacketCaptureDelete, + MigrateState: ResourceNetworkPacketCaptureMigrateState, + SchemaVersion: 1, + Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -210,29 +214,25 @@ func resourceArmNetworkPacketCaptureRead(d *schema.ResourceData, meta interface{ ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseAzureResourceID(d.Id()) + id, err := parse.NetworkPacketCaptureID(d.Id()) if err != nil { return err } - resourceGroup := id.ResourceGroup - watcherName := id.Path["networkWatchers"] - name := id.Path["packetCaptures"] - - resp, err := client.Get(ctx, resourceGroup, watcherName, name) + resp, err := client.Get(ctx, id.ResourceGroup, id.WatcherName, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[WARN] Packet Capture %q (Watcher %q / Resource Group %q) %qw not found - removing from state", name, watcherName, resourceGroup, id) + log.Printf("[WARN] Packet Capture %q (Watcher %q / Resource Group %q) %qw not found - removing from state", id.Name, id.WatcherName, id.ResourceGroup, id) d.SetId("") return nil } - return fmt.Errorf("Error reading Packet Capture %q (Watcher %q / Resource Group %q) %+v", name, watcherName, resourceGroup, err) + return fmt.Errorf("Error reading Packet Capture %q (Watcher %q / Resource Group %q) %+v", id.Name, id.WatcherName, id.ResourceGroup, err) } - d.Set("name", name) - d.Set("network_watcher_name", watcherName) - d.Set("resource_group_name", resourceGroup) + d.Set("name", id.Name) + d.Set("network_watcher_name", id.WatcherName) + d.Set("resource_group_name", id.ResourceGroup) if props := resp.PacketCaptureResultProperties; props != nil { d.Set("target_resource_id", props.Target) @@ -259,22 +259,18 @@ func resourceArmNetworkPacketCaptureDelete(d *schema.ResourceData, meta interfac ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := azure.ParseAzureResourceID(d.Id()) + id, err := parse.NetworkPacketCaptureID(d.Id()) if err != nil { return err } - resourceGroup := id.ResourceGroup - watcherName := id.Path["networkWatchers"] - name := id.Path["packetCaptures"] - - future, err := client.Delete(ctx, resourceGroup, watcherName, name) + future, err := client.Delete(ctx, id.ResourceGroup, id.WatcherName, id.Name) if err != nil { if response.WasNotFound(future.Response()) { return nil } - return fmt.Errorf("Error deleting Packet Capture %q (Watcher %q / Resource Group %q): %+v", name, watcherName, resourceGroup, err) + return fmt.Errorf("Error deleting Packet Capture %q (Watcher %q / Resource Group %q): %+v", id.Name, id.WatcherName, id.ResourceGroup, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { @@ -282,7 +278,7 @@ func resourceArmNetworkPacketCaptureDelete(d *schema.ResourceData, meta interfac return nil } - return fmt.Errorf("Error waiting for the deletion of Packet Capture %q (Watcher %q / Resource Group %q): %+v", name, watcherName, resourceGroup, err) + return fmt.Errorf("Error waiting for the deletion of Packet Capture %q (Watcher %q / Resource Group %q): %+v", id.Name, id.WatcherName, id.ResourceGroup, err) } return nil diff --git a/azurerm/internal/services/network/parse/network_packet_capture.go b/azurerm/internal/services/network/parse/network_packet_capture.go new file mode 100644 index 000000000000..fdf0f26b3e25 --- /dev/null +++ b/azurerm/internal/services/network/parse/network_packet_capture.go @@ -0,0 +1,34 @@ +package parse + +import "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + +type NetworkPacketCaptureId struct { + ResourceGroup string + WatcherName string + Name string +} + +func NetworkPacketCaptureID(input string) (*NetworkPacketCaptureId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + packetCapture := NetworkPacketCaptureId{ + ResourceGroup: id.ResourceGroup, + } + + if packetCapture.WatcherName, err = id.PopSegment("networkWatchers"); err != nil { + return nil, err + } + + if packetCapture.Name, err = id.PopSegment("packetCaptures"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &packetCapture, nil +} diff --git a/azurerm/internal/services/network/parse/network_packet_capture_test.go b/azurerm/internal/services/network/parse/network_packet_capture_test.go new file mode 100644 index 000000000000..c9d5d8907cf3 --- /dev/null +++ b/azurerm/internal/services/network/parse/network_packet_capture_test.go @@ -0,0 +1,90 @@ +package parse + +import ( + "testing" +) + +func TestNetworkPacketCaptureID(t *testing.T) { + testData := []struct { + Name string + Input string + Error bool + Expect *NetworkPacketCaptureId + }{ + { + Name: "Empty", + Input: "", + Error: true, + }, + { + Name: "No Resource Groups Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000", + Error: true, + }, + { + Name: "No Resource Groups Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", + Error: true, + }, + { + Name: "Resource Group ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", + Error: true, + }, + { + Name: "Missing Network Watcher Key", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkWatchers/", + Error: true, + }, + { + Name: "Missing Network Watcher Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkWatchers/watcher1", + Error: true, + }, + { + Name: "Missing Network Packet Capture Key", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkWatchers/watcher1/packetCaptures", + Error: true, + }, + { + Name: "Namespace Network Packet Capture Value", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkWatchers/watcher1/packetCaptures/packetCapture1", + Error: false, + Expect: &NetworkPacketCaptureId{ + ResourceGroup: "group1", + WatcherName: "watcher1", + Name: "packetCapture1", + }, + }, + { + Name: "Wrong Segment", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/networkWatchers/watcher1/NetworkPacketCaptures/packetCapture1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := NetworkPacketCaptureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expect.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expect.Name, actual.Name) + } + + if actual.WatcherName != v.Expect.WatcherName { + t.Fatalf("Expected %q but got %q for Name", v.Expect.WatcherName, actual.WatcherName) + } + + if actual.ResourceGroup != v.Expect.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.ResourceGroup, actual.ResourceGroup) + } + } +} From ef1537fdda8a0f37c6f461a61d8f7b2585d29270 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 21 Aug 2020 13:23:21 +0800 Subject: [PATCH 3/6] Update code --- .../network/network_packet_capture_migration_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/network/network_packet_capture_migration_resource.go b/azurerm/internal/services/network/network_packet_capture_migration_resource.go index 79d1ecd3a726..d88f2e994f69 100644 --- a/azurerm/internal/services/network/network_packet_capture_migration_resource.go +++ b/azurerm/internal/services/network/network_packet_capture_migration_resource.go @@ -8,17 +8,17 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func ResourceNetworkPacketCaptureMigrateState(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { +func ResourceNetworkPacketCaptureMigrateState(v int, is *terraform.InstanceState, _ interface{}) (*terraform.InstanceState, error) { switch v { case 0: log.Println("[INFO] Found AzureRM Network Packet Capture State v0; migrating to v1") - return resourceNetworkPacketCaptureStateV0toV1(is, meta) + return resourceNetworkPacketCaptureStateV0toV1(is) default: return is, fmt.Errorf("Unexpected schema version: %d", v) } } -func resourceNetworkPacketCaptureStateV0toV1(is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { +func resourceNetworkPacketCaptureStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { if is.Empty() { log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") return is, nil From b2f02cb98f021e5c9faa9792eabb2d1dd08be31e Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 11 Sep 2020 12:52:00 +0800 Subject: [PATCH 4/6] Update code --- .../migration/network_packet_capture.go | 127 ++++++++++++++++++ ...twork_packet_capture_migration_resource.go | 36 ----- .../network_packet_capture_resource.go | 13 +- 3 files changed, 137 insertions(+), 39 deletions(-) create mode 100644 azurerm/internal/services/network/migration/network_packet_capture.go delete mode 100644 azurerm/internal/services/network/network_packet_capture_migration_resource.go diff --git a/azurerm/internal/services/network/migration/network_packet_capture.go b/azurerm/internal/services/network/migration/network_packet_capture.go new file mode 100644 index 000000000000..e202bf1525e5 --- /dev/null +++ b/azurerm/internal/services/network/migration/network_packet_capture.go @@ -0,0 +1,127 @@ +package migration + +import ( + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "log" + "strings" +) + +func NetworkPacketCaptureV0Schema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "network_watcher_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "target_resource_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "maximum_bytes_per_packet": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Default: 0, + }, + + "maximum_bytes_per_session": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Default: 1073741824, + }, + + "maximum_capture_duration": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + Default: 18000, + }, + + "storage_location": { + Type: schema.TypeList, + Required: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "file_path": { + Type: schema.TypeString, + Optional: true, + }, + "storage_account_id": { + Type: schema.TypeString, + Optional: true, + }, + "storage_path": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + + "filter": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "local_ip_address": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "local_port": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "protocol": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "remote_ip_address": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "remote_port": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + }, + }, + }, + } +} + +func NetworkPacketCaptureV0ToV1(rawState map[string]interface{}, _ interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + newId := strings.Replace(rawState["id"].(string), "/NetworkPacketCaptures/", "/packetCaptures/", 1) + + log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) + + rawState["id"] = newId + + return rawState, nil +} diff --git a/azurerm/internal/services/network/network_packet_capture_migration_resource.go b/azurerm/internal/services/network/network_packet_capture_migration_resource.go deleted file mode 100644 index d88f2e994f69..000000000000 --- a/azurerm/internal/services/network/network_packet_capture_migration_resource.go +++ /dev/null @@ -1,36 +0,0 @@ -package network - -import ( - "fmt" - "log" - "strings" - - "github.com/hashicorp/terraform-plugin-sdk/terraform" -) - -func ResourceNetworkPacketCaptureMigrateState(v int, is *terraform.InstanceState, _ interface{}) (*terraform.InstanceState, error) { - switch v { - case 0: - log.Println("[INFO] Found AzureRM Network Packet Capture State v0; migrating to v1") - return resourceNetworkPacketCaptureStateV0toV1(is) - default: - return is, fmt.Errorf("Unexpected schema version: %d", v) - } -} - -func resourceNetworkPacketCaptureStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { - if is.Empty() { - log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") - return is, nil - } - - log.Printf("[DEBUG] ARM Network Packet Capture before Migration: %#v", is.Attributes) - - newID := strings.Replace(is.Attributes["id"], "/NetworkPacketCaptures/", "/packetCaptures/", 1) - is.Attributes["id"] = newID - is.ID = newID - - log.Printf("[DEBUG] ARM Network Packet Capture Attributes after State Migration: %#v", is.Attributes) - - return is, nil -} diff --git a/azurerm/internal/services/network/network_packet_capture_resource.go b/azurerm/internal/services/network/network_packet_capture_resource.go index 4c708a228582..7f5ac421c680 100644 --- a/azurerm/internal/services/network/network_packet_capture_resource.go +++ b/azurerm/internal/services/network/network_packet_capture_resource.go @@ -12,6 +12,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/network/migration" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/network/parse" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -23,9 +24,6 @@ func resourceArmNetworkPacketCapture() *schema.Resource { Read: resourceArmNetworkPacketCaptureRead, Delete: resourceArmNetworkPacketCaptureDelete, - MigrateState: ResourceNetworkPacketCaptureMigrateState, - SchemaVersion: 1, - Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, @@ -143,6 +141,15 @@ func resourceArmNetworkPacketCapture() *schema.Resource { }, }, }, + + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.NetworkPacketCaptureV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.NetworkPacketCaptureV0ToV1, + Version: 0, + }, + }, } } From 50d801a6e4971b2e9203b00336d54586c97b9941 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 11 Sep 2020 12:54:32 +0800 Subject: [PATCH 5/6] Update code --- .../services/network/migration/network_packet_capture.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/network/migration/network_packet_capture.go b/azurerm/internal/services/network/migration/network_packet_capture.go index e202bf1525e5..7ebc7b5821ed 100644 --- a/azurerm/internal/services/network/migration/network_packet_capture.go +++ b/azurerm/internal/services/network/migration/network_packet_capture.go @@ -1,9 +1,10 @@ package migration import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "log" "strings" + + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ) func NetworkPacketCaptureV0Schema() *schema.Resource { From 9564c83d988d3baa9b3787257b95bac444f68d90 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 11 Sep 2020 13:43:04 +0800 Subject: [PATCH 6/6] Update code --- .../migration/network_packet_capture.go | 6 ++++++ .../network/network_packet_capture_resource.go | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/azurerm/internal/services/network/migration/network_packet_capture.go b/azurerm/internal/services/network/migration/network_packet_capture.go index 7ebc7b5821ed..7d2f5d0b96c5 100644 --- a/azurerm/internal/services/network/migration/network_packet_capture.go +++ b/azurerm/internal/services/network/migration/network_packet_capture.go @@ -66,10 +66,12 @@ func NetworkPacketCaptureV0Schema() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "storage_account_id": { Type: schema.TypeString, Optional: true, }, + "storage_path": { Type: schema.TypeString, Computed: true, @@ -89,21 +91,25 @@ func NetworkPacketCaptureV0Schema() *schema.Resource { Optional: true, ForceNew: true, }, + "local_port": { Type: schema.TypeString, Optional: true, ForceNew: true, }, + "protocol": { Type: schema.TypeString, Required: true, ForceNew: true, }, + "remote_ip_address": { Type: schema.TypeString, Optional: true, ForceNew: true, }, + "remote_port": { Type: schema.TypeString, Optional: true, diff --git a/azurerm/internal/services/network/network_packet_capture_resource.go b/azurerm/internal/services/network/network_packet_capture_resource.go index 7f5ac421c680..24ce519d7ce2 100644 --- a/azurerm/internal/services/network/network_packet_capture_resource.go +++ b/azurerm/internal/services/network/network_packet_capture_resource.go @@ -28,6 +28,15 @@ func resourceArmNetworkPacketCapture() *schema.Resource { State: schema.ImportStatePassthrough, }, + SchemaVersion: 1, + StateUpgraders: []schema.StateUpgrader{ + { + Type: migration.NetworkPacketCaptureV0Schema().CoreConfigSchema().ImpliedType(), + Upgrade: migration.NetworkPacketCaptureV0ToV1, + Version: 0, + }, + }, + Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), Read: schema.DefaultTimeout(5 * time.Minute), @@ -141,15 +150,6 @@ func resourceArmNetworkPacketCapture() *schema.Resource { }, }, }, - - SchemaVersion: 1, - StateUpgraders: []schema.StateUpgrader{ - { - Type: migration.NetworkPacketCaptureV0Schema().CoreConfigSchema().ImpliedType(), - Upgrade: migration.NetworkPacketCaptureV0ToV1, - Version: 0, - }, - }, } }