@@ -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+
4059func 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+
119180const testAccClbTargetGroupAttachment = `
120181 resource "tencentcloud_vpc" "foo" {
121182 name = "guagua-ci-temp-test"
0 commit comments