Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for IPV6_ONLY stackType configurations #12485

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions mmv1/products/compute/Subnetwork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ examples:
network_name: 'network-reserved-secondary-range'
primary_range_name: 'reserved-primary'
secondary_range_name: 'reserved-secondary'
- name: 'subnetwork_ipv6_only_internal'
primary_resource_id: 'subnetwork-ipv6-only'
exclude_docs: true
vars:
subnetwork_name: 'subnet-ipv6-only'
network_name: 'network-ipv6-only'
- name: 'subnetwork_ipv6_only_external'
primary_resource_id: 'subnetwork-ipv6-only'
exclude_docs: true
vars:
subnetwork_name: 'subnet-ipv6-only'
network_name: 'network-ipv6-only'
virtual_fields:
- name: 'send_secondary_ip_range_if_empty'
description: |
Expand Down Expand Up @@ -403,6 +415,7 @@ properties:
enum_values:
- 'IPV4_ONLY'
- 'IPV4_IPV6'
- 'IPV6_ONLY'
- name: 'ipv6AccessType'
type: Enum
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_compute_subnetwork" "subnetwork-ipv6-only" {
name = "{{index $.Vars "subnetwork_name"}}"
region = "us-central1"
network = google_compute_network.custom-test.id
stack_type = "IPV6_ONLY"
ipv6_access_type = "EXTERNAL"
}

resource "google_compute_network" "custom-test" {
name = "{{index $.Vars "network_name"}}"
auto_create_subnetworks = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "google_compute_subnetwork" "subnetwork-ipv6-only" {
name = "{{index $.Vars "subnetwork_name"}}"
region = "us-central1"
network = google_compute_network.custom-test.id
stack_type = "IPV6_ONLY"
ipv6_access_type = "INTERNAL"
}

resource "google_compute_network" "custom-test" {
name = "{{index $.Vars "network_name"}}"
auto_create_subnetworks = false
enable_ula_internal_ipv6 = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func ResourceComputeInstance() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false),
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", "IPV6_ONLY", ""}, false),
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.`,
},

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

"ipv6_access_config": {
Type: schema.TypeList,
Optional: true,
Optional: true,
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.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ Google Cloud KMS.`,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false),
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", "IPV6_ONLY", ""}, false),
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.`,
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4278,6 +4278,27 @@ func TestAccComputeInstance_NicStackTypeUpdate(t *testing.T) {
})
}

func TestAccComputeInstance_NicStackType_IPV6(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"instance_name": fmt.Sprintf("tf-test-compute-instance-%s", acctest.RandString(t, 10)),
"suffix": acctest.RandString(t, 10),
"env_region": envvar.GetTestRegionFromEnv(),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeInstance_nicStackTypeUpdate_ipv6(context),
},
},
})
}


func testAccCheckComputeInstanceDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
config := acctest.GoogleProviderConfig(t)
Expand Down Expand Up @@ -11368,3 +11389,47 @@ resource "google_compute_instance" "foobar" {
}
`, context)
}

func testAccComputeInstance_nicStackTypeUpdate_ipv6(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_compute_image" "my_image" {
family = "debian-11"
project = "debian-cloud"
}

resource "google_compute_network" "inst-test-network" {
name = "tf-test-network-%{suffix}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "inst-test-subnetwork" {
name = "tf-test-compute-subnet-%{suffix}"
region = "%{env_region}"
ipv6_access_type = "EXTERNAL"
stack_type = "IPV6_ONLY"
network = google_compute_network.inst-test-network.id
}

resource "google_compute_instance" "foobar" {
name = "%{instance_name}"
machine_type = "e2-medium"
zone = "%{env_region}-a"

boot_disk {
initialize_params {
image = data.google_compute_image.my_image.self_link
}
}

network_interface {
network = google_compute_network.inst-test-network.id
subnetwork = google_compute_subnetwork.inst-test-subnetwork.id
stack_type = "IPV6_ONLY"

ipv6_access_config {
network_tier = "PREMIUM"
}
}
}
`, context)
}
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ Google Cloud KMS.`,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6", ""}, false),
ValidateFunc: validation.StringInSlice([]string{"IPV4_ONLY", "IPV4_IPV6","IPV6_ONLY", ""}, false),
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.`,
},

Expand All @@ -538,6 +538,7 @@ Google Cloud KMS.`,
"ipv6_access_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
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.`,
Elem: &schema.Resource{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ is desired, you will need to modify your state file manually using

* `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}`.

* `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.
* `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.

* `ipv6_access_config` - (Optional) An array of IPv6 access configurations for this interface.
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ The following arguments are supported:

* `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.

* `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.
* `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.

* `ipv6_access_config` - (Optional) An array of IPv6 access configurations for this interface.
Currently, only one IPv6 access config, DIRECT_IPV6, is supported. If there is no ipv6AccessConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ The following arguments are supported:

* `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.

* `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.
* `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.

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