Skip to content

Commit

Permalink
populate external_ipv6 (#6244)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
edwardmedia and Edward Sun authored Jul 11, 2022
1 parent 4aecac1 commit 12ba99e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func TestAccComputeInstance_IPv6(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceExists(
t, "google_compute_instance.foobar", &instance),
testAccCheckComputeInstanceIpv6AccessConfigHasExternalIPv6(&instance),
),
},
{
Expand Down Expand Up @@ -2545,6 +2546,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,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
}
Expand Down

0 comments on commit 12ba99e

Please sign in to comment.