@@ -331,6 +331,37 @@ func TestAccComputeSubnetwork_flowLogsMigrate(t *testing.T) {
331331 })
332332}
333333
334+ func TestAccComputeSubnetwork_ipv6 (t * testing.T ) {
335+ t .Parallel ()
336+
337+ cnName := fmt .Sprintf ("tf-test-%s" , randString (t , 10 ))
338+ subnetworkName := fmt .Sprintf ("tf-test-%s" , randString (t , 10 ))
339+
340+ vcrTest (t , resource.TestCase {
341+ PreCheck : func () { testAccPreCheck (t ) },
342+ Providers : testAccProviders ,
343+ CheckDestroy : testAccCheckComputeSubnetworkDestroyProducer (t ),
344+ Steps : []resource.TestStep {
345+ {
346+ Config : testAccComputeSubnetwork_ipv4 (cnName , subnetworkName ),
347+ },
348+ {
349+ ResourceName : "google_compute_subnetwork.subnetwork" ,
350+ ImportState : true ,
351+ ImportStateVerify : true ,
352+ },
353+ {
354+ Config : testAccComputeSubnetwork_ipv6 (cnName , subnetworkName ),
355+ },
356+ {
357+ ResourceName : "google_compute_subnetwork.subnetwork" ,
358+ ImportState : true ,
359+ ImportStateVerify : true ,
360+ },
361+ },
362+ })
363+ }
364+
334365func testAccCheckComputeSubnetworkExists (t * testing.T , n string , subnetwork * compute.Subnetwork ) resource.TestCheckFunc {
335366 return func (s * terraform.State ) error {
336367 rs , ok := s .RootModule ().Resources [n ]
@@ -728,3 +759,37 @@ resource "google_compute_subnetwork" "network-with-flow-logs" {
728759}
729760` , cnName , subnetworkName )
730761}
762+
763+ func testAccComputeSubnetwork_ipv4 (cnName , subnetworkName string ) string {
764+ return fmt .Sprintf (`
765+ resource "google_compute_network" "custom-test" {
766+ name = "%s"
767+ auto_create_subnetworks = false
768+ }
769+
770+ resource "google_compute_subnetwork" "subnetwork" {
771+ name = "%s"
772+ ip_cidr_range = "10.0.0.0/16"
773+ region = "us-central1"
774+ network = google_compute_network.custom-test.self_link
775+ }
776+ ` , cnName , subnetworkName )
777+ }
778+
779+ func testAccComputeSubnetwork_ipv6 (cnName , subnetworkName string ) string {
780+ return fmt .Sprintf (`
781+ resource "google_compute_network" "custom-test" {
782+ name = "%s"
783+ auto_create_subnetworks = false
784+ }
785+
786+ resource "google_compute_subnetwork" "subnetwork" {
787+ name = "%s"
788+ ip_cidr_range = "10.0.0.0/16"
789+ region = "us-central1"
790+ network = google_compute_network.custom-test.self_link
791+ stack_type = "IPV4_IPV6"
792+ ipv6_access_type = "EXTERNAL"
793+ }
794+ ` , cnName , subnetworkName )
795+ }
0 commit comments