From fc674d3ae1d0666d0090f1164134519e09995a68 Mon Sep 17 00:00:00 2001 From: Wmxs <54929266+WeiMengXS@users.noreply.github.com> Date: Fri, 19 Jan 2024 15:55:28 +0800 Subject: [PATCH] fix: foceNew --- ...esource_tc_clb_target_group_attachments.go | 3 +- ...ce_tc_clb_target_group_attachments_test.go | 40 +++++++++++++++++++ .../services/clb/service_tencentcloud_clb.go | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go index 21e3f0bfdc..6246a85cd8 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go @@ -317,6 +317,7 @@ func margeReadRequest(d *schema.ResourceData) ([]string, map[string]struct{}) { } associationsSet[strings.Join(ids, tccommon.FILED_SP)] = struct{}{} + fmt.Println("create cdr", strings.Join(ids, tccommon.FILED_SP)) } } if len(targetGroupList) < 1 && !isBindFromClb(resourceId) { @@ -330,7 +331,7 @@ func processIds(id string, dMap map[string]interface{}, key string, clbFlag bool } else if !clbFlag && key == "target_group_id" { *ids = append(*ids, id) } else { - if v, ok := dMap[key]; ok { + if v, ok := dMap[key]; ok && v.(string) != "" { *ids = append(*ids, v.(string)) } else { *ids = append(*ids, "null") diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go index 238ba68cfc..cc9838db73 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go @@ -67,6 +67,25 @@ func TestAccTencentCloudClbTargetGroupAttachmentsResource_sync(t *testing.T) { }) } +func TestAccTencentCloudClbTargetGroupAttachmentsResource_tcp(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccClbTargetGroupAttachmentsTCP, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_attachments.target_group_attachments", "id"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_attachments.target_group_attachments", "target_group_id"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_attachments.target_group_attachments", "associations.#"), + ), + }, + }, + }) +} + const testAccClbTargetGroupAttachments = ` resource "tencentcloud_clb_instance" "clb_basic" { @@ -353,3 +372,24 @@ resource "tencentcloud_clb_target_group_attachments" "target_group_attachments1" } } ` +const testAccClbTargetGroupAttachmentsTCP = ` +resource "tencentcloud_clb_instance" "clb_basic" { + network_type = "OPEN" + clb_name = "tf_test_clb_attach_1" + vpc_id = "vpc-efc9vddt" +} +resource "tencentcloud_clb_listener" "public_listeners" { + clb_id = tencentcloud_clb_instance.clb_basic.id + protocol = "TCP" + port = "8090" + listener_name = "iac-test-attach" +} +resource "tencentcloud_clb_target_group_attachments" "target_group_attachments" { + target_group_id = "lbtg-fa1l7oh2" + associations { + load_balancer_id = tencentcloud_clb_instance.clb_basic.id + listener_id = tencentcloud_clb_listener.public_listeners.listener_id + } +} +} +` diff --git a/tencentcloud/services/clb/service_tencentcloud_clb.go b/tencentcloud/services/clb/service_tencentcloud_clb.go index 6d801bfdb3..b883d76eb7 100644 --- a/tencentcloud/services/clb/service_tencentcloud_clb.go +++ b/tencentcloud/services/clb/service_tencentcloud_clb.go @@ -2336,6 +2336,7 @@ func (me *ClbService) DescribeClbTargetGroupAttachmentsById(ctx context.Context, } key := strings.Join(info, tccommon.FILED_SP) + fmt.Println("read cdr", key) if _, ok := associationsSet[key]; ok { result = append(result, key) }