From dd4ea30f60b1e7d1e4965ccadebf145975a0d43f Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 26 Sep 2023 16:10:38 -0700 Subject: [PATCH 1/8] update externalIpv6Prefex to not be output only --- mmv1/products/compute/Subnetwork.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv1/products/compute/Subnetwork.yaml b/mmv1/products/compute/Subnetwork.yaml index 1c48d02c2f40..76cccfaa8490 100644 --- a/mmv1/products/compute/Subnetwork.yaml +++ b/mmv1/products/compute/Subnetwork.yaml @@ -372,6 +372,6 @@ properties: The range of internal IPv6 addresses that are owned by this subnetwork. - !ruby/object:Api::Type::String name: 'externalIpv6Prefix' - output: true + default_from_api: true description: | - The range of external IPv6 addresses that are owned by this subnetwork. + The range of external IPv6 addresses that are owned by this subnetwork. Defaults to "2600:1900:4000:1ae::/64". From f0143b8dd77b48f14055aa1d87f13dc71a8c375f Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 17 Oct 2023 15:26:19 -0700 Subject: [PATCH 2/8] WIP: adding attribute to update tests --- .../resource_compute_subnetwork_test.go.erb | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb index ad8d6dcd2003..79529422c677 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb @@ -144,6 +144,19 @@ func TestAccComputeSubnetwork_update(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + // + Config: testAccComputeSubnetwork_update4(cnName, "10.2.0.0/24", subnetworkName), + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeSubnetworkExists( + t, "google_compute_subnetwork.network-with-private-google-access", &subnetwork), + ), + }, + { + ResourceName: "google_compute_subnetwork.network-with-private-google-access", + ImportState: true, + ImportStateVerify: true, + }, }, }) @@ -510,6 +523,31 @@ resource "google_compute_subnetwork" "network-with-private-google-access" { range_name = "tf-test-secondary-range-update" ip_cidr_range = "192.168.10.0/24" } + + external_ipv6_prefix = "2001:1234:5678:1234" +} +`, cnName, subnetworkName, cidrRange) +} + +func testAccComputeSubnetwork_update4(cnName, cidrRange, subnetworkName string) string { + return fmt.Sprintf(` +resource "google_compute_network" "custom-test" { + name = "%s" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "network-with-private-google-access" { + name = "%s" + ip_cidr_range = "%s" + region = "us-central1" + network = google_compute_network.custom-test.self_link + + secondary_ip_range { + range_name = "tf-test-secondary-range-update" + ip_cidr_range = "192.168.10.0/24" + } + + external_ipv6_prefix = "2001:1234:5678:4321" } `, cnName, subnetworkName, cidrRange) } From 2d5d572bdfb2b868fbd0a26aa78b87a8e0caf12e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 20 Oct 2023 12:43:35 -0700 Subject: [PATCH 3/8] remove tests --- .../resource_compute_subnetwork_test.go.erb | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb index 0cec3b5fab2f..cf3e5d345cf0 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb @@ -144,19 +144,6 @@ func TestAccComputeSubnetwork_update(t *testing.T) { ImportState: true, ImportStateVerify: true, }, - { - // - Config: testAccComputeSubnetwork_update4(cnName, "10.2.0.0/24", subnetworkName), - Check: resource.ComposeTestCheckFunc( - testAccCheckComputeSubnetworkExists( - t, "google_compute_subnetwork.network-with-private-google-access", &subnetwork), - ), - }, - { - ResourceName: "google_compute_subnetwork.network-with-private-google-access", - ImportState: true, - ImportStateVerify: true, - }, }, }) @@ -643,23 +630,6 @@ resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" `, cnName, subnetworkName) } -func testAccComputeSubnetwork_secondaryIpRanges_update4(cnName, subnetworkName string) string { - return fmt.Sprintf(` -resource "google_compute_network" "custom-test" { - name = "%s" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" { - name = "%s" - ip_cidr_range = "10.2.0.0/16" - region = "us-central1" - network = google_compute_network.custom-test.self_link - secondary_ip_range = [] -} -`, cnName, subnetworkName) -} - func testAccComputeSubnetwork_flowLogs(cnName, subnetworkName string) string { return fmt.Sprintf(` resource "google_compute_network" "custom-test" { From 75851ad0e356a812b9ed0c2a68676b597ae16471 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 20 Oct 2023 13:07:41 -0700 Subject: [PATCH 4/8] remove update4 config --- .../resource_compute_subnetwork_test.go.erb | 84 ++++--------------- 1 file changed, 17 insertions(+), 67 deletions(-) diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb index cf3e5d345cf0..ad8d6dcd2003 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb @@ -369,29 +369,6 @@ func TestAccComputeSubnetwork_ipv6(t *testing.T) { }) } -func TestAccComputeSubnetwork_internal_ipv6(t *testing.T) { - t.Parallel() - - cnName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) - subnetworkName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckComputeSubnetworkDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccComputeSubnetwork_internal_ipv6(cnName, subnetworkName), - }, - { - ResourceName: "google_compute_subnetwork.subnetwork", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccCheckComputeSubnetworkExists(t *testing.T, n string, subnetwork *compute.Subnetwork) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -533,31 +510,6 @@ resource "google_compute_subnetwork" "network-with-private-google-access" { range_name = "tf-test-secondary-range-update" ip_cidr_range = "192.168.10.0/24" } - - external_ipv6_prefix = "2001:1234:5678:1234" -} -`, cnName, subnetworkName, cidrRange) -} - -func testAccComputeSubnetwork_update4(cnName, cidrRange, subnetworkName string) string { - return fmt.Sprintf(` -resource "google_compute_network" "custom-test" { - name = "%s" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "network-with-private-google-access" { - name = "%s" - ip_cidr_range = "%s" - region = "us-central1" - network = google_compute_network.custom-test.self_link - - secondary_ip_range { - range_name = "tf-test-secondary-range-update" - ip_cidr_range = "192.168.10.0/24" - } - - external_ipv6_prefix = "2001:1234:5678:4321" } `, cnName, subnetworkName, cidrRange) } @@ -630,6 +582,23 @@ resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" `, cnName, subnetworkName) } +func testAccComputeSubnetwork_secondaryIpRanges_update4(cnName, subnetworkName string) string { + return fmt.Sprintf(` +resource "google_compute_network" "custom-test" { + name = "%s" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "network-with-private-secondary-ip-ranges" { + name = "%s" + ip_cidr_range = "10.2.0.0/16" + region = "us-central1" + network = google_compute_network.custom-test.self_link + secondary_ip_range = [] +} +`, cnName, subnetworkName) +} + func testAccComputeSubnetwork_flowLogs(cnName, subnetworkName string) string { return fmt.Sprintf(` resource "google_compute_network" "custom-test" { @@ -831,22 +800,3 @@ resource "google_compute_subnetwork" "subnetwork" { } `, cnName, subnetworkName) } - -func testAccComputeSubnetwork_internal_ipv6(cnName, subnetworkName string) string { - return fmt.Sprintf(` -resource "google_compute_network" "custom-test" { - name = "%s" - auto_create_subnetworks = false - enable_ula_internal_ipv6 = true -} - -resource "google_compute_subnetwork" "subnetwork" { - name = "%s" - ip_cidr_range = "10.0.0.0/16" - region = "us-central1" - network = google_compute_network.custom-test.self_link - stack_type = "IPV4_IPV6" - ipv6_access_type = "INTERNAL" -} -`, cnName, subnetworkName) -} From 695469b903aef419b0ebaaf7737e47e8ce975ab0 Mon Sep 17 00:00:00 2001 From: Mauricio Alvarez Leon <65101411+BBBmau@users.noreply.github.com> Date: Fri, 20 Oct 2023 13:08:32 -0700 Subject: [PATCH 5/8] Update mmv1/products/compute/Subnetwork.yaml Co-authored-by: Riley Karson --- mmv1/products/compute/Subnetwork.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/compute/Subnetwork.yaml b/mmv1/products/compute/Subnetwork.yaml index def4c601584f..0a8634f30909 100644 --- a/mmv1/products/compute/Subnetwork.yaml +++ b/mmv1/products/compute/Subnetwork.yaml @@ -394,7 +394,7 @@ properties: name: 'externalIpv6Prefix' default_from_api: true description: | - The range of external IPv6 addresses that are owned by this subnetwork. Defaults to "2600:1900:4000:1ae::/64". + The range of external IPv6 addresses that are owned by this subnetwork. - !ruby/object:Api::Type::Boolean name: 'allowSubnetCidrRoutesOverlap' default_from_api: true From 82624ff174c07d67e3dc4fb400ef48517bf15984 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 20 Oct 2023 13:13:37 -0700 Subject: [PATCH 6/8] add back internalipv6 test --- .../resource_compute_subnetwork_test.go.erb | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb index ad8d6dcd2003..8d57305a8f13 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb @@ -369,6 +369,29 @@ func TestAccComputeSubnetwork_ipv6(t *testing.T) { }) } +func TestAccComputeSubnetwork_internal_ipv6(t *testing.T) { + t.Parallel() + + cnName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) + subnetworkName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckComputeSubnetworkDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeSubnetwork_internal_ipv6(cnName, subnetworkName), + }, + { + ResourceName: "google_compute_subnetwork.subnetwork", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckComputeSubnetworkExists(t *testing.T, n string, subnetwork *compute.Subnetwork) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -800,3 +823,22 @@ resource "google_compute_subnetwork" "subnetwork" { } `, cnName, subnetworkName) } + +func testAccComputeSubnetwork_internal_ipv6(cnName, subnetworkName string) string { + return fmt.Sprintf(` +resource "google_compute_network" "custom-test" { + name = "%s" + auto_create_subnetworks = false + enable_ula_internal_ipv6 = true +} + +resource "google_compute_subnetwork" "subnetwork" { + name = "%s" + ip_cidr_range = "10.0.0.0/16" + region = "us-central1" + network = google_compute_network.custom-test.self_link + stack_type = "IPV4_IPV6" + ipv6_access_type = "INTERNAL" +} +`, cnName, subnetworkName) +} \ No newline at end of file From b67a969e8e27e0cf319dede71ab74dc6055348b8 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 20 Oct 2023 13:15:02 -0700 Subject: [PATCH 7/8] add endline --- .../services/compute/resource_compute_subnetwork_test.go.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb index 8d57305a8f13..a20a1b44d6fd 100644 --- a/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb +++ b/mmv1/third_party/terraform/services/compute/resource_compute_subnetwork_test.go.erb @@ -841,4 +841,4 @@ resource "google_compute_subnetwork" "subnetwork" { ipv6_access_type = "INTERNAL" } `, cnName, subnetworkName) -} \ No newline at end of file +} From 9d5d2a9a3f0dee1a9f1aa5bb3187914d830a5b35 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Wed, 8 Nov 2023 18:13:37 -0800 Subject: [PATCH 8/8] fix lint error --- mmv1/products/compute/Subnetwork.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/products/compute/Subnetwork.yaml b/mmv1/products/compute/Subnetwork.yaml index 0a8634f30909..c15b6e3ca304 100644 --- a/mmv1/products/compute/Subnetwork.yaml +++ b/mmv1/products/compute/Subnetwork.yaml @@ -408,4 +408,3 @@ properties: existing resources are dropped and prevented from leaving the VPC. Setting this field to true will allow these packets to match dynamic routes injected via BGP even if their destinations match existing subnet ranges. -