Skip to content

Commit 8ad5a00

Browse files
author
“guojunchu”
committed
add tcp/udp listener target group attachment
1 parent e030927 commit 8ad5a00

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tencentcloud/resource_tc_clb_target_group_attachment_test.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ func TestAccTencentClbTargetGroupAttachmentResource(t *testing.T) {
3737
})
3838
}
3939

40+
func TestAccTencentClbTargetGroupAttachmentHttpResource(t *testing.T) {
41+
resource.Test(t, resource.TestCase{
42+
PreCheck: func() { testAccPreCheck(t) },
43+
Providers: testAccProviders,
44+
CheckDestroy: testAccCheckClbTargetGroupAttachmentDestroy,
45+
Steps: []resource.TestStep{
46+
{
47+
Config: testAccClbTargetGroupAttachmentHttp,
48+
Check: resource.ComposeTestCheckFunc(
49+
testAccCheckClbTargetGroupAttachmentExists(clbTargetGroupAttachment),
50+
resource.TestCheckResourceAttrSet(clbTargetGroupAttachment, "clb_id"),
51+
resource.TestCheckResourceAttrSet(clbTargetGroupAttachment, "listener_id"),
52+
resource.TestCheckResourceAttrSet(clbTargetGroupAttachment, "target_group_id"),
53+
),
54+
},
55+
},
56+
})
57+
}
58+
4059
func testAccCheckClbTargetGroupAttachmentDestroy(s *terraform.State) error {
4160
var (
4261
clbService = ClbService{
@@ -116,6 +135,48 @@ func testAccCheckClbTargetGroupAttachmentExists(n string) resource.TestCheckFunc
116135
}
117136
}
118137

138+
const testAccClbTargetGroupAttachmentHttp = `
139+
resource "tencentcloud_vpc" "foo" {
140+
name = "guagua-ci-temp-test"
141+
cidr_block = "10.0.0.0/16"
142+
}
143+
144+
resource "tencentcloud_clb_instance" "clb_basic" {
145+
network_type = "OPEN"
146+
clb_name = "tf-clb-basic"
147+
vpc_id = tencentcloud_vpc.foo.id
148+
}
149+
150+
resource "tencentcloud_clb_listener" "listener_basic" {
151+
clb_id = tencentcloud_clb_instance.clb_basic.id
152+
port = 1
153+
protocol = "HTTP"
154+
listener_name = "listener_basic"
155+
}
156+
157+
resource "tencentcloud_clb_listener_rule" "rule_basic" {
158+
clb_id = tencentcloud_clb_instance.clb_basic.id
159+
listener_id = tencentcloud_clb_listener.listener_basic.listener_id
160+
domain = "abc.com"
161+
url = "/"
162+
session_expire_time = 30
163+
scheduler = "WRR"
164+
target_type = "TARGETGROUP"
165+
}
166+
167+
resource "tencentcloud_clb_target_group" "test"{
168+
target_group_name = "test-target-keep-1"
169+
vpc_id = tencentcloud_vpc.foo.id
170+
}
171+
172+
resource "tencentcloud_clb_target_group_attachment" "group" {
173+
clb_id = tencentcloud_clb_instance.clb_basic.id
174+
listener_id = tencentcloud_clb_listener.listener_basic.listener_id
175+
rule_id = tencentcloud_clb_listener_rule.rule_basic.rule_id
176+
target_group_id = tencentcloud_clb_target_group.test.id
177+
}
178+
`
179+
119180
const testAccClbTargetGroupAttachment = `
120181
resource "tencentcloud_vpc" "foo" {
121182
name = "guagua-ci-temp-test"

0 commit comments

Comments
 (0)