Skip to content

Commit 62b022d

Browse files
committed
fix: compute instance internal ipv6 prefix length is not set in creation and read in syncing
1 parent df0fd02 commit 62b022d

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

mmv1/third_party/terraform/services/compute/compute_instance_helpers.go.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ func flattenNetworkInterfaces(d *schema.ResourceData, config *transport_tpg.Conf
508508
"ipv6_access_config": flattenIpv6AccessConfigs(iface.Ipv6AccessConfigs),
509509
"ipv6_address": iface.Ipv6Address,
510510
"queue_count": iface.QueueCount,
511+
"internal_ipv6_prefix_length": iface.InternalIpv6PrefixLength,
511512
}
512513
// Instance template interfaces never have names, so they're absent
513514
// in the instance template network_interface schema. We want to use the
@@ -643,6 +644,7 @@ func expandNetworkInterfaces(d tpgresource.TerraformResourceData, config *transp
643644
QueueCount: int64(data["queue_count"].(int)),
644645
Ipv6AccessConfigs: expandIpv6AccessConfigs(data["ipv6_access_config"].([]interface{})),
645646
Ipv6Address: data["ipv6_address"].(string),
647+
InternalIpv6PrefixLength: int64(data["internal_ipv6_prefix_length"].(int)),
646648
}
647649
}
648650
return ifaces, nil

mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.tmpl

+64
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,30 @@ func TestAccComputeInstance_internalIPv6(t *testing.T) {
587587
})
588588
}
589589

590+
func TestAccComputeInstance_internalIPv6PrefixLength(t *testing.T) {
591+
t.Parallel()
592+
593+
var instance compute.Instance
594+
var instanceName = fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
595+
596+
acctest.VcrTest(t, resource.TestCase{
597+
PreCheck: func() { acctest.AccTestPreCheck(t) },
598+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
599+
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
600+
Steps: []resource.TestStep{
601+
{
602+
Config: testAccComputeInstance_internalIpv6PrefixLength("96", instanceName),
603+
Check: resource.ComposeTestCheckFunc(
604+
testAccCheckComputeInstanceExists(
605+
t, "google_compute_instance.foobar", &instance),
606+
testAccCheckComputeInstanceIpv6AccessConfigHasInternalIPv6(&instance),
607+
),
608+
},
609+
computeInstanceImportStep("us-west2-a", instanceName, []string{"allow_stopping_for_update"}),
610+
},
611+
})
612+
}
613+
590614
func TestAccComputeInstance_PTRRecord(t *testing.T) {
591615
t.Parallel()
592616

@@ -6220,6 +6244,46 @@ func testAccComputeInstance_internalIpv6(ip, instance string) string {
62206244
`, instance, instance, ip, instance)
62216245
}
62226246

6247+
func testAccComputeInstance_internalIpv6PrefixLength(length, instance string) string {
6248+
return fmt.Sprintf(`
6249+
resource "google_compute_network" "vpc" {
6250+
name = "%s-network"
6251+
auto_create_subnetworks = "false"
6252+
enable_ula_internal_ipv6 = true
6253+
}
6254+
6255+
resource "google_compute_subnetwork" "subnetwork" {
6256+
name = "%s-subnetwork"
6257+
ip_cidr_range = "10.0.0.0/22"
6258+
region = "us-west2"
6259+
stack_type = "IPV4_IPV6"
6260+
ipv6_access_type = "INTERNAL"
6261+
network = google_compute_network.vpc.id
6262+
}
6263+
6264+
resource "google_compute_instance" "foobar" {
6265+
name = "%s"
6266+
machine_type = "e2-micro"
6267+
allow_stopping_for_update = true
6268+
zone = "us-west2-a"
6269+
boot_disk {
6270+
auto_delete = false
6271+
initialize_params {
6272+
image = "debian-cloud/debian-11"
6273+
}
6274+
}
6275+
network_interface {
6276+
network = google_compute_network.vpc.self_link
6277+
subnetwork = google_compute_subnetwork.subnetwork.self_link
6278+
stack_type = "IPV4_IPV6"
6279+
access_config {
6280+
network_tier = "STANDARD"
6281+
}
6282+
internal_ipv6_prefix_length = %s
6283+
}
6284+
}
6285+
`, instance, instance, instance, length)
6286+
}
62236287
func testAccComputeInstance_ipv6ExternalReservation(instance string) string {
62246288
return fmt.Sprintf(`
62256289
resource "google_compute_address" "ipv6-address" {

0 commit comments

Comments
 (0)