Skip to content

Commit

Permalink
fix: foceNew
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiMengXS committed Jan 19, 2024
1 parent cc780c1 commit fc674d3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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
}
}
}
`
1 change: 1 addition & 0 deletions tencentcloud/services/clb/service_tencentcloud_clb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit fc674d3

Please sign in to comment.