Skip to content

Commit

Permalink
make enableProxyProtocol field updatable in service_attachment (#8840) (
Browse files Browse the repository at this point in the history
#15716)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Sep 4, 2023
1 parent a930629 commit 0b063b1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/8840.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added update support for `enable_proxy_protocol` to`google_compute_service_attachment` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -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" {
Expand Down

0 comments on commit 0b063b1

Please sign in to comment.