Skip to content

Commit 2948ee7

Browse files
karolgorczli82016
authored andcommitted
Allow for IPV6_ONLY stackType configurations (GoogleCloudPlatform#12485)
Co-authored-by: Zhenhua Li <[email protected]>
1 parent 3e0a969 commit 2948ee7

10 files changed

+111
-7
lines changed

mmv1/products/compute/Subnetwork.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,18 @@ examples:
124124
network_name: 'network-reserved-secondary-range'
125125
primary_range_name: 'reserved-primary'
126126
secondary_range_name: 'reserved-secondary'
127+
- name: 'subnetwork_ipv6_only_internal'
128+
primary_resource_id: 'subnetwork-ipv6-only'
129+
exclude_docs: true
130+
vars:
131+
subnetwork_name: 'subnet-ipv6-only'
132+
network_name: 'network-ipv6-only'
133+
- name: 'subnetwork_ipv6_only_external'
134+
primary_resource_id: 'subnetwork-ipv6-only'
135+
exclude_docs: true
136+
vars:
137+
subnetwork_name: 'subnet-ipv6-only'
138+
network_name: 'network-ipv6-only'
127139
virtual_fields:
128140
- name: 'send_secondary_ip_range_if_empty'
129141
description: |
@@ -403,6 +415,7 @@ properties:
403415
enum_values:
404416
- 'IPV4_ONLY'
405417
- 'IPV4_IPV6'
418+
- 'IPV6_ONLY'
406419
- name: 'ipv6AccessType'
407420
type: Enum
408421
description: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "google_compute_subnetwork" "subnetwork-ipv6-only" {
2+
name = "{{index $.Vars "subnetwork_name"}}"
3+
region = "us-central1"
4+
network = google_compute_network.custom-test.id
5+
stack_type = "IPV6_ONLY"
6+
ipv6_access_type = "EXTERNAL"
7+
}
8+
9+
resource "google_compute_network" "custom-test" {
10+
name = "{{index $.Vars "network_name"}}"
11+
auto_create_subnetworks = false
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "google_compute_subnetwork" "subnetwork-ipv6-only" {
2+
name = "{{index $.Vars "subnetwork_name"}}"
3+
region = "us-central1"
4+
network = google_compute_network.custom-test.id
5+
stack_type = "IPV6_ONLY"
6+
ipv6_access_type = "INTERNAL"
7+
}
8+
9+
resource "google_compute_network" "custom-test" {
10+
name = "{{index $.Vars "network_name"}}"
11+
auto_create_subnetworks = false
12+
enable_ula_internal_ipv6 = true
13+
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ func ResourceComputeInstance() *schema.Resource {
536536
Type: schema.TypeString,
537537
Optional: true,
538538
Computed: true,
539-
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false),
539+
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", "IPV6_ONLY", ""}, false),
540540
Description: `The stack type for this network interface to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used.`,
541541
},
542542

@@ -548,7 +548,7 @@ func ResourceComputeInstance() *schema.Resource {
548548

549549
"ipv6_access_config": {
550550
Type: schema.TypeList,
551-
Optional: true,
551+
Optional: true,
552552
Description: `An array of IPv6 access configurations for this interface. Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig specified, then this instance will have no external IPv6 Internet access.`,
553553
Elem: &schema.Resource{
554554
Schema: map[string]*schema.Schema{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ Google Cloud KMS.`,
556556
Optional: true,
557557
Computed: true,
558558
ForceNew: true,
559-
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false),
559+
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", "IPV6_ONLY", ""}, false),
560560
Description: `The stack type for this network interface to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used.`,
561561
},
562562

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

+65
Original file line numberDiff line numberDiff line change
@@ -4278,6 +4278,27 @@ func TestAccComputeInstance_NicStackTypeUpdate(t *testing.T) {
42784278
})
42794279
}
42804280

4281+
func TestAccComputeInstance_NicStackType_IPV6(t *testing.T) {
4282+
t.Parallel()
4283+
context := map[string]interface{}{
4284+
"instance_name": fmt.Sprintf("tf-test-compute-instance-%s", acctest.RandString(t, 10)),
4285+
"suffix": acctest.RandString(t, 10),
4286+
"env_region": envvar.GetTestRegionFromEnv(),
4287+
}
4288+
4289+
acctest.VcrTest(t, resource.TestCase{
4290+
PreCheck: func() { acctest.AccTestPreCheck(t) },
4291+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
4292+
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
4293+
Steps: []resource.TestStep{
4294+
{
4295+
Config: testAccComputeInstance_nicStackTypeUpdate_ipv6(context),
4296+
},
4297+
},
4298+
})
4299+
}
4300+
4301+
42814302
func testAccCheckComputeInstanceDestroyProducer(t *testing.T) func(s *terraform.State) error {
42824303
return func(s *terraform.State) error {
42834304
config := acctest.GoogleProviderConfig(t)
@@ -11368,3 +11389,47 @@ resource "google_compute_instance" "foobar" {
1136811389
}
1136911390
`, context)
1137011391
}
11392+
11393+
func testAccComputeInstance_nicStackTypeUpdate_ipv6(context map[string]interface{}) string {
11394+
return acctest.Nprintf(`
11395+
data "google_compute_image" "my_image" {
11396+
family = "debian-11"
11397+
project = "debian-cloud"
11398+
}
11399+
11400+
resource "google_compute_network" "inst-test-network" {
11401+
name = "tf-test-network-%{suffix}"
11402+
auto_create_subnetworks = false
11403+
}
11404+
11405+
resource "google_compute_subnetwork" "inst-test-subnetwork" {
11406+
name = "tf-test-compute-subnet-%{suffix}"
11407+
region = "%{env_region}"
11408+
ipv6_access_type = "EXTERNAL"
11409+
stack_type = "IPV6_ONLY"
11410+
network = google_compute_network.inst-test-network.id
11411+
}
11412+
11413+
resource "google_compute_instance" "foobar" {
11414+
name = "%{instance_name}"
11415+
machine_type = "e2-medium"
11416+
zone = "%{env_region}-a"
11417+
11418+
boot_disk {
11419+
initialize_params {
11420+
image = data.google_compute_image.my_image.self_link
11421+
}
11422+
}
11423+
11424+
network_interface {
11425+
network = google_compute_network.inst-test-network.id
11426+
subnetwork = google_compute_subnetwork.inst-test-subnetwork.id
11427+
stack_type = "IPV6_ONLY"
11428+
11429+
ipv6_access_config {
11430+
network_tier = "PREMIUM"
11431+
}
11432+
}
11433+
}
11434+
`, context)
11435+
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ Google Cloud KMS.`,
524524
Optional: true,
525525
Computed: true,
526526
ForceNew: true,
527-
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false),
527+
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6","IPV6_ONLY", ""}, false),
528528
Description: `The stack type for this network interface to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used.`,
529529
},
530530

@@ -538,6 +538,7 @@ Google Cloud KMS.`,
538538
"ipv6_access_config": {
539539
Type: schema.TypeList,
540540
Optional: true,
541+
Computed: true,
541542
ForceNew: true,
542543
Description: `An array of IPv6 access configurations for this interface. Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig specified, then this instance will have no external IPv6 Internet access.`,
543544
Elem: &schema.Resource{

mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ is desired, you will need to modify your state file manually using
401401

402402
* `network_attachment` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) The URL of the network attachment that this interface should connect to in the following format: `projects/{projectNumber}/regions/{region_name}/networkAttachments/{network_attachment_name}`.
403403

404-
* `stack_type` - (Optional) The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6 or IPV4_ONLY. If not specified, IPV4_ONLY will be used.
404+
* `stack_type` - (Optional) The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6, IPV6_ONLY or IPV4_ONLY. If not specified, IPV4_ONLY will be used.
405405

406406
* `ipv6_access_config` - (Optional) An array of IPv6 access configurations for this interface.
407407
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig

mmv1/third_party/terraform/website/docs/r/compute_instance_template.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ The following arguments are supported:
563563

564564
* `nic_type` - (Optional) The type of vNIC to be used on this interface. Possible values: GVNIC, VIRTIO_NET. In the beta provider the additional values of MRDMA and IRDMA are supported.
565565

566-
* `stack_type` - (Optional) The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6 or IPV4_ONLY. If not specified, IPV4_ONLY will be used.
566+
* `stack_type` - (Optional) The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6, IPV6_ONLY or IPV4_ONLY. If not specified, IPV4_ONLY will be used.
567567

568568
* `ipv6_access_config` - (Optional) An array of IPv6 access configurations for this interface.
569569
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig

mmv1/third_party/terraform/website/docs/r/compute_region_instance_template.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ The following arguments are supported:
529529

530530
* `nic_type` - (Optional) The type of vNIC to be used on this interface. Possible values: GVNIC, VIRTIO_NET. In the beta provider the additional values of MRDMA and IRDMA are supported.
531531

532-
* `stack_type` - (Optional) The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6 or IPV4_ONLY. If not specified, IPV4_ONLY will be used.
532+
* `stack_type` - (Optional) The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6, IPV6_ONLY or IPV4_ONLY. If not specified, IPV4_ONLY will be used.
533533

534534
* `ipv6_access_config` - (Optional) An array of IPv6 access configurations for this interface.
535535
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig

0 commit comments

Comments
 (0)