Skip to content

Commit

Permalink
populate external_ipv6 (#6244) (#12072)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun authored Jul 11, 2022
1 parent 145a696 commit 84d1902
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6244.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed missing `network_interface.0.ipv6_access_config.0.external_ipv6` output on `google_compute_instance`
```
1 change: 1 addition & 0 deletions google/compute_instance_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions google/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ func TestAccComputeInstance_IPv6(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceExists(
t, "google_compute_instance.foobar", &instance),
testAccCheckComputeInstanceIpv6AccessConfigHasExternalIPv6(&instance),
),
},
{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 84d1902

Please sign in to comment.