@@ -116,7 +116,7 @@ func TestAccTencentCloudClbInstance_internal(t *testing.T) {
116116 })
117117}
118118
119- func TestAccTencentCloudClbInstanceTargetGroup (t * testing.T ) {
119+ func TestAccTencentCloudClbInstance_default_enable (t * testing.T ) {
120120 t .Parallel ()
121121
122122 resource .Test (t , resource.TestCase {
@@ -125,23 +125,67 @@ func TestAccTencentCloudClbInstanceTargetGroup(t *testing.T) {
125125 CheckDestroy : testAccCheckClbInstanceDestroy ,
126126 Steps : []resource.TestStep {
127127 {
128- Config : testAccClbInstanceTargetGroup ,
128+ Config : testAccClbInstance_default_enable ,
129129 Check : resource .ComposeTestCheckFunc (
130- testAccCheckClbInstanceExists ("tencentcloud_clb_instance.target_group" ),
131- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "target_group_name" , "tgt_grp_test" ),
132- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "port" , "33" ),
133- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "target_group_instances.bind_ip" , "10.0.0.4" ),
134- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "target_group_instances.port" , "33" ),
130+ testAccCheckClbInstanceExists ("tencentcloud_clb_instance.default_enable" ),
131+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "network_type" , "OPEN" ),
132+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "clb_name" , "my_open_clb" ),
133+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "project_id" , "0" ),
134+ resource .TestCheckResourceAttrSet ("tencentcloud_clb_instance.default_enable" , "vpc_id" ),
135+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "load_balancer_pass_to_target" , "true" ),
136+ resource .TestCheckResourceAttrSet ("tencentcloud_clb_instance.default_enable" , "security_groups.0" ),
137+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "target_region_info_region" , "ap-guangzhou" ),
138+ resource .TestCheckResourceAttrSet ("tencentcloud_clb_instance.default_enable" , "target_region_info_vpc_id" ),
139+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "tags.test" , "open" ),
135140 ),
136141 },
137142 {
138- Config : testAccClbInstanceTargetGroupUpdate ,
143+ Config : testAccClbInstance_default_enable_open ,
139144 Check : resource .ComposeTestCheckFunc (
140- testAccCheckClbInstanceExists ("tencentcloud_clb_instance.target_group" ),
141- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "target_group_name" , "tgt_grp_test" ),
142- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "port" , "33" ),
143- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "target_group_instances.bind_ip" , "10.0.0.4" ),
144- resource .TestCheckResourceAttr ("tencentcloud_clb_instance.target_group" , "target_group_instances.port" , "44" ),
145+ testAccCheckClbInstanceExists ("tencentcloud_clb_instance.default_enable" ),
146+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "network_type" , "OPEN" ),
147+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "clb_name" , "my_open_clb" ),
148+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "project_id" , "0" ),
149+ resource .TestCheckResourceAttrSet ("tencentcloud_clb_instance.default_enable" , "vpc_id" ),
150+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "load_balancer_pass_to_target" , "true" ),
151+ resource .TestCheckResourceAttrSet ("tencentcloud_clb_instance.default_enable" , "security_groups.0" ),
152+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "target_region_info_region" , "ap-guangzhou" ),
153+ resource .TestCheckResourceAttrSet ("tencentcloud_clb_instance.default_enable" , "target_region_info_vpc_id" ),
154+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.default_enable" , "tags.test" , "hello" ),
155+ ),
156+ },
157+ },
158+ })
159+ }
160+
161+ func TestAccTencentCloudClbInstance_multiple_instance (t * testing.T ) {
162+ t .Parallel ()
163+
164+ resource .Test (t , resource.TestCase {
165+ PreCheck : func () { testAccPreCheck (t ) },
166+ Providers : testAccProviders ,
167+ CheckDestroy : testAccCheckClbInstanceDestroy ,
168+ Steps : []resource.TestStep {
169+ {
170+ Config : testAccClbInstance__multi_instance ,
171+ Check : resource .ComposeTestCheckFunc (
172+ testAccCheckClbInstanceExists ("tencentcloud_clb_instance.multiple_instance" ),
173+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "network_type" , "OPEN" ),
174+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "clb_name" , "my_open_clb" ),
175+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "master_zone_id" , "10001" ),
176+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "slave_zone_id" , "10002" ),
177+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "tags.test" , "mytest" ),
178+ ),
179+ },
180+ {
181+ Config : testAccClbInstance__multi_instance_update ,
182+ Check : resource .ComposeTestCheckFunc (
183+ testAccCheckClbInstanceExists ("tencentcloud_clb_instance.multiple_instance" ),
184+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "network_type" , "OPEN" ),
185+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "clb_name" , "my_open_clb" ),
186+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "master_zone_id" , "10001" ),
187+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "slave_zone_id" , "10002" ),
188+ resource .TestCheckResourceAttr ("tencentcloud_clb_instance.multiple_instance" , "tags.test" , "open" ),
145189 ),
146190 },
147191 },
@@ -313,24 +357,118 @@ resource "tencentcloud_clb_instance" "clb_open" {
313357}
314358`
315359
316- const testAccClbInstanceTargetGroup = `
317- resource "tencentcloud_clb_instance" "target_group" {
318- target_group_name = "tgt_grp_test"
319- port = 33
320- target_group_instances {
321- bind_ip = "10.0.0.4"
322- port = 18800
323- }
360+ const testAccClbInstance_default_enable = `
361+ variable "availability_zone" {
362+ default = "ap-guangzhou-1"
363+ }
364+
365+ resource "tencentcloud_subnet" "subnet" {
366+ availability_zone = var.availability_zone
367+ name = "sdk-feature-test"
368+ vpc_id = tencentcloud_vpc.foo.id
369+ cidr_block = "10.0.20.0/28"
370+ is_multicast = false
371+ }
372+
373+ resource "tencentcloud_security_group" "sglab" {
374+ name = "sg_o0ek7r93"
375+ description = "favourite sg"
376+ project_id = 0
377+ }
378+
379+ resource "tencentcloud_vpc" "foo" {
380+ name = "for-my-open-clb"
381+ cidr_block = "10.0.0.0/16"
382+
383+ tags = {
384+ "test" = "mytest"
385+ }
386+ }
387+
388+ resource "tencentcloud_clb_instance" "default_enable" {
389+ network_type = "OPEN"
390+ clb_name = "my-open-clb"
391+ project_id = 0
392+ vpc_id = tencentcloud_vpc.foo.id
393+ load_balancer_pass_to_target = true
394+
395+ security_groups = [tencentcloud_security_group.sglab.id]
396+ target_region_info_region = "ap-guangzhou"
397+ target_region_info_vpc_id = tencentcloud_vpc.foo.id
398+
399+ tags = {
400+ test = "open"
401+ }
402+ }
403+ `
404+
405+ const testAccClbInstance_default_enable_open = `
406+ variable "availability_zone" {
407+ default = "ap-guangzhou-1"
408+ }
409+
410+ resource "tencentcloud_subnet" "subnet" {
411+ availability_zone = var.availability_zone
412+ name = "sdk-feature-test"
413+ vpc_id = tencentcloud_vpc.foo.id
414+ cidr_block = "10.0.20.0/28"
415+ is_multicast = false
416+ }
417+
418+ resource "tencentcloud_security_group" "sglab" {
419+ name = "sg_o0ek7r93"
420+ description = "favourite sg"
421+ project_id = 0
422+ }
423+
424+ resource "tencentcloud_vpc" "foo" {
425+ name = "for-my-open-clb"
426+ cidr_block = "10.0.0.0/16"
427+
428+ tags = {
429+ "test" = "mytest"
430+ }
431+ }
432+
433+ resource "tencentcloud_clb_instance" "default_enable" {
434+ network_type = "OPEN"
435+ clb_name = "my-open-clb"
436+ project_id = 0
437+ vpc_id = tencentcloud_vpc.foo.id
438+ load_balancer_pass_to_target = true
439+
440+ security_groups = [tencentcloud_security_group.sglab.id]
441+ target_region_info_region = "ap-guangzhou"
442+ target_region_info_vpc_id = tencentcloud_vpc.foo.id
443+
444+ tags = {
445+ test = "hello"
446+ }
324447}
325448`
326449
327- const testAccClbInstanceTargetGroupUpdate = `
328- resource "tencentcloud_clb_instance" "target_group" {
329- target_group_name = "tgt_grp_test"
330- port = 44
331- target_group_instances {
332- bind_ip = "10.0.0.4"
333- port = 18800
334- }
450+ const testAccClbInstance__multi_instance = `
451+ resource "tencentcloud_clb_instance" "multiple_instance" {
452+ network_type = "OPEN"
453+ clb_name = "my-open-clb"
454+ master_zone_id = "10001"
455+ slave_zone_id = "10002"
456+
457+ tags = {
458+ test = "open"
459+ }
460+ }
461+ `
462+
463+ const testAccClbInstance__multi_instance_update = `
464+ resource "tencentcloud_clb_instance" "multiple_instance" {
465+ network_type = "OPEN"
466+ clb_name = "my-open-clb"
467+ master_zone_id = "10001"
468+ slave_zone_id = "10002"
469+
470+ tags = {
471+ test = "open"
472+ }
335473}
336474`
0 commit comments