Skip to content

Commit f42d230

Browse files
authored
fix: clb attachment - disable target diff if using TCP-SSL listener (#1092)
1 parent 352f592 commit f42d230

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

tencentcloud/resource_tc_clb_attachment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ func resourceTencentCloudClbServerAttachmentRead(d *schema.ResourceData, meta in
424424
}
425425
}
426426
}
427-
} else if *instance.Protocol == CLB_LISTENER_PROTOCOL_TCP || *instance.Protocol == CLB_LISTENER_PROTOCOL_UDP {
427+
// TCP / UDP / TCP_SSL
428+
} else if instance.Targets != nil {
428429
onlineTargets = instance.Targets
429430
}
430431

tencentcloud/resource_tc_clb_attachment_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ func TestAccTencentCloudClbServerAttachment_tcp(t *testing.T) {
3636
resource.TestCheckResourceAttr("tencentcloud_clb_attachment.foo", "protocol_type", "TCP"),
3737
resource.TestCheckResourceAttr("tencentcloud_clb_attachment.foo", "targets.#", "1"),
3838
),
39+
}, {
40+
Config: testAccClbServerAttachment_tcp_update_ssl,
41+
Check: resource.ComposeTestCheckFunc(
42+
testAccCheckClbServerAttachmentExists("tencentcloud_clb_attachment.foo"),
43+
resource.TestCheckResourceAttrSet("tencentcloud_clb_attachment.foo", "clb_id"),
44+
resource.TestCheckResourceAttrSet("tencentcloud_clb_attachment.foo", "listener_id"),
45+
resource.TestCheckResourceAttr("tencentcloud_clb_attachment.foo", "protocol_type", "TCP_SSL"),
46+
resource.TestCheckResourceAttr("tencentcloud_clb_attachment.foo", "targets.#", "1"),
47+
),
3948
},
4049
},
4150
})
@@ -154,6 +163,10 @@ func testAccCheckClbServerAttachmentExists(n string) resource.TestCheckFunc {
154163
}
155164

156165
const testAccClbServerAttachment_tcp = instanceCommonTestCase + `
166+
data "tencentcloud_ssl_certificates" "foo" {
167+
name = "keep"
168+
}
169+
157170
resource "tencentcloud_clb_instance" "foo" {
158171
network_type = "OPEN"
159172
clb_name = "tf-clb-attach-tcp-test"
@@ -187,6 +200,10 @@ resource "tencentcloud_clb_attachment" "foo" {
187200
`
188201

189202
const testAccClbServerAttachment_tcp_update = instanceCommonTestCase + `
203+
data "tencentcloud_ssl_certificates" "foo" {
204+
name = "keep"
205+
}
206+
190207
resource "tencentcloud_clb_instance" "foo" {
191208
network_type = "OPEN"
192209
clb_name = "tf-clb-attach-tcp-test"
@@ -219,6 +236,41 @@ resource "tencentcloud_clb_attachment" "foo" {
219236
}
220237
`
221238

239+
const testAccClbServerAttachment_tcp_update_ssl = instanceCommonTestCase + `
240+
data "tencentcloud_ssl_certificates" "foo" {
241+
name = "keep"
242+
}
243+
244+
resource "tencentcloud_clb_instance" "foo" {
245+
network_type = "OPEN"
246+
clb_name = "tf-clb-attach-tcp-ssl"
247+
vpc_id = var.cvm_vpc_id
248+
}
249+
250+
# This is will force new as expected
251+
resource "tencentcloud_clb_listener" "foo" {
252+
clb_id = tencentcloud_clb_instance.foo.id
253+
listener_name = "tf-clb-attach-tcp-ssl"
254+
port = 44
255+
protocol = "TCP_SSL"
256+
health_check_switch = true
257+
scheduler = "WRR"
258+
certificate_ssl_mode = "UNIDIRECTIONAL"
259+
certificate_id = data.tencentcloud_ssl_certificates.foo.certificates.0.id
260+
}
261+
262+
resource "tencentcloud_clb_attachment" "foo" {
263+
clb_id = tencentcloud_clb_instance.foo.id
264+
listener_id = tencentcloud_clb_listener.foo.listener_id
265+
266+
targets {
267+
instance_id = tencentcloud_instance.default.id
268+
port = 23
269+
weight = 50
270+
}
271+
}
272+
`
273+
222274
const testAccClbServerAttachment_http = instanceCommonTestCase + `
223275
resource "tencentcloud_clb_instance" "foo" {
224276
network_type = "OPEN"

0 commit comments

Comments
 (0)