From b07f4c6b8e31a4004a2b72130a7d76e93cc43e8c Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Mon, 11 Jul 2022 15:17:03 +0000 Subject: [PATCH] populate external_ipv6 (#6244) Co-authored-by: Edward Sun Signed-off-by: Modular Magician --- .changelog/6244.txt | 3 +++ google/compute_instance_helpers.go | 1 + google/resource_compute_instance_test.go | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 .changelog/6244.txt diff --git a/.changelog/6244.txt b/.changelog/6244.txt new file mode 100644 index 00000000000..89d8de63606 --- /dev/null +++ b/.changelog/6244.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: fixed missing `network_interface.0.ipv6_access_config.0.external_ipv6` output on `google_compute_instance` +``` diff --git a/google/compute_instance_helpers.go b/google/compute_instance_helpers.go index 9028dd69adc..204e9d02062 100644 --- a/google/compute_instance_helpers.go +++ b/google/compute_instance_helpers.go @@ -175,6 +175,7 @@ func flattenIpv6AccessConfigs(ipv6AccessConfigs []*compute.AccessConfig) []map[s "network_tier": ac.NetworkTier, } flattened[i]["public_ptr_domain_name"] = ac.PublicPtrDomainName + flattened[i]["external_ipv6"] = ac.ExternalIpv6 } return flattened } diff --git a/google/resource_compute_instance_test.go b/google/resource_compute_instance_test.go index 493852ce845..0f8bcbf934a 100644 --- a/google/resource_compute_instance_test.go +++ b/google/resource_compute_instance_test.go @@ -263,6 +263,7 @@ func TestAccComputeInstance_IPv6(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckComputeInstanceExists( t, "google_compute_instance.foobar", &instance), + testAccCheckComputeInstanceIpv6AccessConfigHasExternalIPv6(&instance), ), }, { @@ -2514,6 +2515,20 @@ func testAccCheckComputeInstanceAccessConfigHasNatIP(instance *compute.Instance) } } +func testAccCheckComputeInstanceIpv6AccessConfigHasExternalIPv6(instance *compute.Instance) resource.TestCheckFunc { + return func(s *terraform.State) error { + for _, i := range instance.NetworkInterfaces { + for _, c := range i.Ipv6AccessConfigs { + if c.ExternalIpv6 == "" { + return fmt.Errorf("no External IPv6") + } + } + } + + return nil + } +} + func testAccCheckComputeInstanceAccessConfigHasPTR(instance *compute.Instance) resource.TestCheckFunc { return func(s *terraform.State) error { for _, i := range instance.NetworkInterfaces {