From 5976eb52435e0cf849bb8c1896f56db1aa7d3569 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 30 Sep 2024 09:38:33 -0700 Subject: [PATCH] Revert the promotion of Port Mapping NEGs from GA to Beta (#11854) (#19684) [upstream:2d34af8bcf47b390ede98ace828c98e80cb3acd0] Signed-off-by: Modular Magician --- .changelog/11854.txt | 3 + ...esource_compute_region_network_endpoint.go | 73 -------------- ..._region_network_endpoint_generated_test.go | 4 +- ...n_network_endpoint_group_generated_test.go | 49 ---------- ...ce_compute_region_network_endpoint_test.go | 95 ------------------- ...pute_region_network_endpoint.html.markdown | 10 +- ...egion_network_endpoint_group.html.markdown | 3 + 7 files changed, 16 insertions(+), 221 deletions(-) create mode 100644 .changelog/11854.txt diff --git a/.changelog/11854.txt b/.changelog/11854.txt new file mode 100644 index 00000000000..5d6114eafbb --- /dev/null +++ b/.changelog/11854.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: promoted `client_destination_port` and `instance` fields in `google_compute_region_network_endpoint` resource to GA (revert) +``` \ No newline at end of file diff --git a/google/services/compute/resource_compute_region_network_endpoint.go b/google/services/compute/resource_compute_region_network_endpoint.go index 6b04aacadd5..7b6a6b4a52d 100644 --- a/google/services/compute/resource_compute_region_network_endpoint.go +++ b/google/services/compute/resource_compute_region_network_endpoint.go @@ -67,12 +67,6 @@ func ResourceComputeRegionNetworkEndpoint() *schema.Resource { DiffSuppressFunc: tpgresource.CompareResourceNames, Description: `The network endpoint group this endpoint is part of.`, }, - "client_destination_port": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `Client destination port for the 'GCE_VM_IP_PORTMAP' NEG.`, - }, "fqdn": { Type: schema.TypeString, Optional: true, @@ -82,14 +76,6 @@ func ResourceComputeRegionNetworkEndpoint() *schema.Resource { This can only be specified when network_endpoint_type of the NEG is INTERNET_FQDN_PORT.`, AtLeastOneOf: []string{"fqdn", "ip_address"}, }, - "instance": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The name for a specific VM instance that the IP address belongs to. -This is required for network endpoints of type GCE_VM_IP_PORTMAP.`, - }, "ip_address": { Type: schema.TypeString, Optional: true, @@ -143,18 +129,6 @@ func resourceComputeRegionNetworkEndpointCreate(d *schema.ResourceData, meta int } else if v, ok := d.GetOkExists("fqdn"); !tpgresource.IsEmptyValue(reflect.ValueOf(fqdnProp)) && (ok || !reflect.DeepEqual(v, fqdnProp)) { obj["fqdn"] = fqdnProp } - clientDestinationPortProp, err := expandNestedComputeRegionNetworkEndpointClientDestinationPort(d.Get("client_destination_port"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("client_destination_port"); !tpgresource.IsEmptyValue(reflect.ValueOf(clientDestinationPortProp)) && (ok || !reflect.DeepEqual(v, clientDestinationPortProp)) { - obj["clientDestinationPort"] = clientDestinationPortProp - } - instanceProp, err := expandNestedComputeRegionNetworkEndpointInstance(d.Get("instance"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("instance"); !tpgresource.IsEmptyValue(reflect.ValueOf(instanceProp)) && (ok || !reflect.DeepEqual(v, instanceProp)) { - obj["instance"] = instanceProp - } obj, err = resourceComputeRegionNetworkEndpointEncoder(d, meta, obj) if err != nil { @@ -307,12 +281,6 @@ func resourceComputeRegionNetworkEndpointRead(d *schema.ResourceData, meta inter if err := d.Set("fqdn", flattenNestedComputeRegionNetworkEndpointFqdn(res["fqdn"], d, config)); err != nil { return fmt.Errorf("Error reading RegionNetworkEndpoint: %s", err) } - if err := d.Set("client_destination_port", flattenNestedComputeRegionNetworkEndpointClientDestinationPort(res["clientDestinationPort"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionNetworkEndpoint: %s", err) - } - if err := d.Set("instance", flattenNestedComputeRegionNetworkEndpointInstance(res["instance"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionNetworkEndpoint: %s", err) - } return nil } @@ -381,24 +349,6 @@ func resourceComputeRegionNetworkEndpointDelete(d *schema.ResourceData, meta int toDelete["fqdn"] = fqdnProp } - // Instance - instanceProp, err := expandNestedComputeRegionNetworkEndpointInstance(d.Get("instance"), d, config) - if err != nil { - return err - } - if instanceProp != "" { - toDelete["instance"] = instanceProp - } - - // Client Destination Port - clientDestinationPortProp, err := expandNestedComputeRegionNetworkEndpointClientDestinationPort(d.Get("client_destination_port"), d, config) - if err != nil { - return err - } - if clientDestinationPortProp != "" && d.Get("client_destination_port").(int) > 0 { - toDelete["clientDestinationPort"] = clientDestinationPortProp - } - obj = map[string]interface{}{ "networkEndpoints": []map[string]interface{}{toDelete}, } @@ -468,21 +418,6 @@ func flattenNestedComputeRegionNetworkEndpointFqdn(v interface{}, d *schema.Reso return v } -func flattenNestedComputeRegionNetworkEndpointClientDestinationPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles int given in float64 format - if floatVal, ok := v.(float64); ok { - return int(floatVal) - } - return v -} - -func flattenNestedComputeRegionNetworkEndpointInstance(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - func expandNestedComputeRegionNetworkEndpointPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -495,14 +430,6 @@ func expandNestedComputeRegionNetworkEndpointFqdn(v interface{}, d tpgresource.T return v, nil } -func expandNestedComputeRegionNetworkEndpointClientDestinationPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNestedComputeRegionNetworkEndpointInstance(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func resourceComputeRegionNetworkEndpointEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { // Network Endpoint Group is a URL parameter only, so replace self-link/path with resource name only. if err := d.Set("region_network_endpoint_group", tpgresource.GetResourceNameFromSelfLink(d.Get("region_network_endpoint_group").(string))); err != nil { diff --git a/google/services/compute/resource_compute_region_network_endpoint_generated_test.go b/google/services/compute/resource_compute_region_network_endpoint_generated_test.go index b5826747e29..cc2ea7f5191 100644 --- a/google/services/compute/resource_compute_region_network_endpoint_generated_test.go +++ b/google/services/compute/resource_compute_region_network_endpoint_generated_test.go @@ -49,7 +49,7 @@ func TestAccComputeRegionNetworkEndpoint_regionNetworkEndpointInternetIpPortExam ResourceName: "google_compute_region_network_endpoint.region-internet-ip-port-endpoint", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"instance", "region", "region_network_endpoint_group"}, + ImportStateVerifyIgnore: []string{"region", "region_network_endpoint_group"}, }, }, }) @@ -100,7 +100,7 @@ func TestAccComputeRegionNetworkEndpoint_regionNetworkEndpointInternetFqdnPortEx ResourceName: "google_compute_region_network_endpoint.region-internet-fqdn-port-endpoint", ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"instance", "region", "region_network_endpoint_group"}, + ImportStateVerifyIgnore: []string{"region", "region_network_endpoint_group"}, }, }, }) diff --git a/google/services/compute/resource_compute_region_network_endpoint_group_generated_test.go b/google/services/compute/resource_compute_region_network_endpoint_group_generated_test.go index 139781eef3f..c4e6636e5ab 100644 --- a/google/services/compute/resource_compute_region_network_endpoint_group_generated_test.go +++ b/google/services/compute/resource_compute_region_network_endpoint_group_generated_test.go @@ -509,55 +509,6 @@ resource "google_compute_network" "default" { `, context) } -func TestAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupPortmapExample(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - CheckDestroy: testAccCheckComputeRegionNetworkEndpointGroupDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupPortmapExample(context), - }, - { - ResourceName: "google_compute_region_network_endpoint_group.region_network_endpoint_group_portmap", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"network", "region", "subnetwork"}, - }, - }, - }) -} - -func testAccComputeRegionNetworkEndpointGroup_regionNetworkEndpointGroupPortmapExample(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_compute_region_network_endpoint_group" "region_network_endpoint_group_portmap" { - name = "tf-test-portmap-neg%{random_suffix}" - region = "us-central1" - network = google_compute_network.default.id - subnetwork = google_compute_subnetwork.default.id - - network_endpoint_type = "GCE_VM_IP_PORTMAP" -} - -resource "google_compute_network" "default" { - name = "network%{random_suffix}" -} - -resource "google_compute_subnetwork" "default" { - name = "subnetwork%{random_suffix}" - ip_cidr_range = "10.0.0.0/16" - region = "us-central1" - network = google_compute_network.default.id -} -`, context) -} - func testAccCheckComputeRegionNetworkEndpointGroupDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { for name, rs := range s.RootModule().Resources { diff --git a/google/services/compute/resource_compute_region_network_endpoint_test.go b/google/services/compute/resource_compute_region_network_endpoint_test.go index 5a0f08ed5dd..59871c9b0b8 100644 --- a/google/services/compute/resource_compute_region_network_endpoint_test.go +++ b/google/services/compute/resource_compute_region_network_endpoint_test.go @@ -146,101 +146,6 @@ resource "google_compute_region_network_endpoint" "add2" { `, context) + testAccComputeRegionNetworkEndpoint_noRegionNetworkEndpoints(context) } -func TestAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapExample(t *testing.T) { - t.Parallel() - - context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), - } - - negId := fmt.Sprintf("projects/%s/regions/%s/networkEndpointGroups/tf-test-portmap-neg%s", - envvar.GetTestProjectFromEnv(), envvar.GetTestRegionFromEnv(), context["random_suffix"]) - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), - Steps: []resource.TestStep{ - { - Config: testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapExample(context), - }, - { - ResourceName: "google_compute_region_network_endpoint.region_network_endpoint_portmap", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"instance", "region", "region_network_endpoint_group"}, - }, - { - // Delete all endpoints - Config: testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapNoEndpointExample(context), - Check: resource.ComposeTestCheckFunc( - testAccCheckComputeRegionNetworkEndpointWithPortsDestroyed(t, negId, "80"), - ), - }, - }, - }) -} - -func testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapNoEndpointExample(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_compute_network" "default" { - name = "network%{random_suffix}" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "default" { - name = "subnetwork%{random_suffix}" - ip_cidr_range = "10.0.0.0/16" - region = "us-central1" - network = google_compute_network.default.id -} - -resource "google_compute_region_network_endpoint_group" default { - name = "tf-test-portmap-neg%{random_suffix}" - region = "us-central1" - network = google_compute_network.default.id - subnetwork = google_compute_subnetwork.default.id - - network_endpoint_type = "GCE_VM_IP_PORTMAP" -} - -data "google_compute_image" "my_image" { - family = "debian-11" - project = "debian-cloud" -} - -resource "google_compute_instance" "default" { - name = "instance%{random_suffix}" - machine_type = "e2-medium" - zone = "us-central1-a" - - boot_disk { - initialize_params { - image = data.google_compute_image.my_image.self_link - } - } - - network_interface { - subnetwork = google_compute_subnetwork.default.id - access_config { - } - } -} -`, context) -} - -func testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapExample(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_compute_region_network_endpoint" "region_network_endpoint_portmap" { - region_network_endpoint_group = google_compute_region_network_endpoint_group.default.name - region = "us-central1" - instance = google_compute_instance.default.self_link - port = 80 - ip_address = google_compute_instance.default.network_interface[0].network_ip - client_destination_port = 8080 -} -`, context) + testAccComputeRegionNetworkEndpoint_regionNetworkEndpointPortmapNoEndpointExample(context) -} - func testAccComputeRegionNetworkEndpoint_noRegionNetworkEndpoints(context map[string]interface{}) string { return acctest.Nprintf(` resource "google_compute_region_network_endpoint_group" "neg" { diff --git a/website/docs/r/compute_region_network_endpoint.html.markdown b/website/docs/r/compute_region_network_endpoint.html.markdown index 3a71068abfb..a5df66f631f 100644 --- a/website/docs/r/compute_region_network_endpoint.html.markdown +++ b/website/docs/r/compute_region_network_endpoint.html.markdown @@ -102,6 +102,7 @@ resource "google_compute_network" "default" { resource "google_compute_network" "default" { name = "network" auto_create_subnetworks = false + provider = google-beta } resource "google_compute_subnetwork" "default" { @@ -109,6 +110,7 @@ resource "google_compute_subnetwork" "default" { ip_cidr_range = "10.0.0.0/16" region = "us-central1" network = google_compute_network.default.id + provider = google-beta } resource "google_compute_region_network_endpoint_group" default { @@ -118,6 +120,7 @@ resource "google_compute_region_network_endpoint_group" default { subnetwork = google_compute_subnetwork.default.id network_endpoint_type = "GCE_VM_IP_PORTMAP" + provider = google-beta } resource "google_compute_region_network_endpoint" "region_network_endpoint_portmap" { @@ -127,11 +130,13 @@ resource "google_compute_region_network_endpoint" "region_network_endpoint_portm port = 80 ip_address = google_compute_instance.default.network_interface[0].network_ip client_destination_port = 8080 + provider = google-beta } data "google_compute_image" "my_image" { family = "debian-11" project = "debian-cloud" + provider = google-beta } resource "google_compute_instance" "default" { @@ -150,6 +155,7 @@ resource "google_compute_instance" "default" { access_config { } } + provider = google-beta } ``` @@ -181,11 +187,11 @@ The following arguments are supported: This can only be specified when network_endpoint_type of the NEG is INTERNET_FQDN_PORT. * `client_destination_port` - - (Optional) + (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) Client destination port for the `GCE_VM_IP_PORTMAP` NEG. * `instance` - - (Optional) + (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) The name for a specific VM instance that the IP address belongs to. This is required for network endpoints of type GCE_VM_IP_PORTMAP. diff --git a/website/docs/r/compute_region_network_endpoint_group.html.markdown b/website/docs/r/compute_region_network_endpoint_group.html.markdown index f1b2e917b1b..4041ee9b574 100644 --- a/website/docs/r/compute_region_network_endpoint_group.html.markdown +++ b/website/docs/r/compute_region_network_endpoint_group.html.markdown @@ -369,10 +369,12 @@ resource "google_compute_region_network_endpoint_group" "region_network_endpoint subnetwork = google_compute_subnetwork.default.id network_endpoint_type = "GCE_VM_IP_PORTMAP" + provider = google-beta } resource "google_compute_network" "default" { name = "network" + provider = google-beta } resource "google_compute_subnetwork" "default" { @@ -380,6 +382,7 @@ resource "google_compute_subnetwork" "default" { ip_cidr_range = "10.0.0.0/16" region = "us-central1" network = google_compute_network.default.id + provider = google-beta } ```