diff --git a/.changelog/8840.txt b/.changelog/8840.txt new file mode 100644 index 00000000000..8594f7d7393 --- /dev/null +++ b/.changelog/8840.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: added update support for `enable_proxy_protocol` to`google_compute_service_attachment` resource +``` diff --git a/google/services/compute/resource_compute_service_attachment.go b/google/services/compute/resource_compute_service_attachment.go index 7a225d3fd6f..11ba0808028 100644 --- a/google/services/compute/resource_compute_service_attachment.go +++ b/google/services/compute/resource_compute_service_attachment.go @@ -56,7 +56,6 @@ values include "ACCEPT_AUTOMATIC", "ACCEPT_MANUAL".`, "enable_proxy_protocol": { Type: schema.TypeBool, Required: true, - ForceNew: true, Description: `If true, enable the proxy protocol which is for supplying client TCP/IP address data in TCP connections that traverse proxies on their way to destination servers.`, @@ -458,6 +457,12 @@ func resourceComputeServiceAttachmentUpdate(d *schema.ResourceData, meta interfa } else if v, ok := d.GetOkExists("nat_subnets"); ok || !reflect.DeepEqual(v, natSubnetsProp) { obj["natSubnets"] = natSubnetsProp } + enableProxyProtocolProp, err := expandComputeServiceAttachmentEnableProxyProtocol(d.Get("enable_proxy_protocol"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("enable_proxy_protocol"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableProxyProtocolProp)) { + obj["enableProxyProtocol"] = enableProxyProtocolProp + } consumerRejectListsProp, err := expandComputeServiceAttachmentConsumerRejectLists(d.Get("consumer_reject_lists"), d, config) if err != nil { return err diff --git a/google/services/compute/resource_compute_service_attachment_test.go b/google/services/compute/resource_compute_service_attachment_test.go index 2d3fc9304c4..d4db972300b 100644 --- a/google/services/compute/resource_compute_service_attachment_test.go +++ b/google/services/compute/resource_compute_service_attachment_test.go @@ -31,7 +31,16 @@ func TestAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(t *test ImportStateVerifyIgnore: []string{"target_service", "region"}, }, { - Config: testAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(context), + Config: testAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(context, true), + }, + { + ResourceName: "google_compute_service_attachment.psc_ilb_service_attachment", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"target_service", "region"}, + }, + { + Config: testAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(context, false), }, { ResourceName: "google_compute_service_attachment.psc_ilb_service_attachment", @@ -50,7 +59,7 @@ resource "google_compute_service_attachment" "psc_ilb_service_attachment" { region = "us-west2" description = "A service attachment configured with Terraform" - enable_proxy_protocol = true + enable_proxy_protocol = false connection_preference = "ACCEPT_AUTOMATIC" nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id] target_service = google_compute_forwarding_rule.psc_ilb_target_service.id @@ -126,7 +135,15 @@ resource "google_compute_subnetwork" "psc_ilb_nat" { `, context) } -func testAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(context map[string]interface{}) string { +func testAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(context map[string]interface{}, preventDestroy bool) string { + context["lifecycle_block"] = "" + if preventDestroy { + context["lifecycle_block"] = ` + lifecycle { + prevent_destroy = true + }` + } + return acctest.Nprintf(` resource "google_compute_service_attachment" "psc_ilb_service_attachment" { name = "tf-test-my-psc-ilb%{random_suffix}" @@ -143,8 +160,8 @@ resource "google_compute_service_attachment" "psc_ilb_service_attachment" { project_id_or_num = "658859330310" connection_limit = 4 } - reconcile_connections = false + %{lifecycle_block} } resource "google_compute_address" "psc_ilb_consumer_address" {