Skip to content

Commit 22f88aa

Browse files
authored
fix(clb): [137108273] tencentcloud_clb_target_group_instance_attachment Query module update returns weight field (#3138)
* add * add * add
1 parent f9856d8 commit 22f88aa

4 files changed

+66
-65
lines changed

.changelog/3138.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_clb_target_group_instance_attachment: Query module update returns weight field
3+
```

tencentcloud/services/clb/resource_tc_clb_target_group_instance_attachment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ func resourceTencentCloudClbTGAttachmentInstanceRead(d *schema.ResourceData, met
120120
_ = d.Set("target_group_id", idSplit[0])
121121
_ = d.Set("bind_ip", idSplit[1])
122122
_ = d.Set("port", helper.StrToInt64(idSplit[2]))
123+
if tgInstance.Weight != nil {
124+
_ = d.Set("weight", *tgInstance.Weight)
125+
}
123126
return nil
124127
}
125128
}

tencentcloud/services/clb/resource_tc_clb_target_group_instance_attachment.md

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,46 @@ Provides a resource to create a CLB target group instance attachment.
33
Example Usage
44

55
```hcl
6-
data "tencentcloud_images" "my_favorite_image" {
6+
data "tencentcloud_availability_zones" "default" {}
7+
8+
data "tencentcloud_images" "images" {
79
image_type = ["PUBLIC_IMAGE"]
810
os_name = "centos"
911
}
1012
11-
data "tencentcloud_instance_types" "my_favorite_instance_types" {
13+
data "tencentcloud_instance_types" "instance_types" {
14+
cpu_core_count = 2
15+
memory_size = 4
1216
filter {
1317
name = "instance-family"
14-
values = ["S3"]
18+
values = ["S5"]
1519
}
16-
17-
cpu_core_count = 1
18-
memory_size = 1
1920
}
2021
21-
data "tencentcloud_availability_zones" "default" {
22-
}
23-
24-
resource "tencentcloud_vpc" "app" {
22+
resource "tencentcloud_vpc" "vpc" {
2523
cidr_block = "10.0.0.0/16"
26-
name = "awesome_app_vpc"
24+
name = "vpc"
2725
}
2826
29-
resource "tencentcloud_subnet" "app" {
30-
vpc_id = tencentcloud_vpc.app.id
27+
resource "tencentcloud_subnet" "subnet" {
28+
vpc_id = tencentcloud_vpc.vpc.id
3129
availability_zone = data.tencentcloud_availability_zones.default.zones.0.name
32-
name = "awesome_app_subnet"
30+
name = "subnet"
3331
cidr_block = "10.0.1.0/24"
3432
}
3533
36-
resource "tencentcloud_instance" "my_awesome_app" {
37-
instance_name = "awesome_app"
34+
resource "tencentcloud_instance" "example" {
35+
instance_name = "tf-example"
3836
availability_zone = data.tencentcloud_availability_zones.default.zones.0.name
39-
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
40-
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
37+
image_id = data.tencentcloud_images.images.images.0.image_id
38+
instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type
4139
system_disk_type = "CLOUD_PREMIUM"
4240
system_disk_size = 50
4341
hostname = "user"
4442
project_id = 0
45-
vpc_id = tencentcloud_vpc.app.id
46-
subnet_id = tencentcloud_subnet.app.id
47-
internet_max_bandwidth_out = 20
43+
vpc_id = tencentcloud_vpc.vpc.id
44+
subnet_id = tencentcloud_subnet.subnet.id
45+
internet_max_bandwidth_out = 100
4846
4947
data_disks {
5048
data_disk_type = "CLOUD_PREMIUM"
@@ -57,28 +55,27 @@ resource "tencentcloud_instance" "my_awesome_app" {
5755
}
5856
}
5957
60-
data "tencentcloud_instances" "foo" {
61-
instance_id = tencentcloud_instance.my_awesome_app.id
58+
data "tencentcloud_instances" "instances" {
59+
instance_id = tencentcloud_instance.example.id
6260
}
6361
64-
resource "tencentcloud_clb_target_group" "test"{
65-
target_group_name = "test"
66-
vpc_id = tencentcloud_vpc.app.id
62+
resource "tencentcloud_clb_target_group" "example" {
63+
target_group_name = "tf-example"
64+
vpc_id = tencentcloud_vpc.vpc.id
6765
}
6866
69-
resource "tencentcloud_clb_target_group_instance_attachment" "test"{
70-
target_group_id = tencentcloud_clb_target_group.test.id
71-
bind_ip = data.tencentcloud_instances.foo.instance_list[0].private_ip
72-
port = 222
73-
weight = 3
67+
resource "tencentcloud_clb_target_group_instance_attachment" "example" {
68+
target_group_id = tencentcloud_clb_target_group.example.id
69+
bind_ip = data.tencentcloud_instances.instances.instance_list[0].private_ip
70+
port = 8080
71+
weight = 10
7472
}
75-
7673
```
7774

7875
Import
7976

8077
CLB target group instance attachment can be imported using the id, e.g.
8178

8279
```
83-
$ terraform import tencentcloud_clb_target_group_instance_attachment.test lbtg-3k3io0i0#172.16.48.18#222
80+
$ terraform import tencentcloud_clb_target_group_instance_attachment.example lbtg-3k3io0i0#172.16.48.18#8080
8481
```

website/docs/r/clb_target_group_instance_attachment.html.markdown

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,46 @@ Provides a resource to create a CLB target group instance attachment.
1414
## Example Usage
1515

1616
```hcl
17-
data "tencentcloud_images" "my_favorite_image" {
17+
data "tencentcloud_availability_zones" "default" {}
18+
19+
data "tencentcloud_images" "images" {
1820
image_type = ["PUBLIC_IMAGE"]
1921
os_name = "centos"
2022
}
2123
22-
data "tencentcloud_instance_types" "my_favorite_instance_types" {
24+
data "tencentcloud_instance_types" "instance_types" {
25+
cpu_core_count = 2
26+
memory_size = 4
2327
filter {
2428
name = "instance-family"
25-
values = ["S3"]
29+
values = ["S5"]
2630
}
27-
28-
cpu_core_count = 1
29-
memory_size = 1
30-
}
31-
32-
data "tencentcloud_availability_zones" "default" {
3331
}
3432
35-
resource "tencentcloud_vpc" "app" {
33+
resource "tencentcloud_vpc" "vpc" {
3634
cidr_block = "10.0.0.0/16"
37-
name = "awesome_app_vpc"
35+
name = "vpc"
3836
}
3937
40-
resource "tencentcloud_subnet" "app" {
41-
vpc_id = tencentcloud_vpc.app.id
38+
resource "tencentcloud_subnet" "subnet" {
39+
vpc_id = tencentcloud_vpc.vpc.id
4240
availability_zone = data.tencentcloud_availability_zones.default.zones.0.name
43-
name = "awesome_app_subnet"
41+
name = "subnet"
4442
cidr_block = "10.0.1.0/24"
4543
}
4644
47-
resource "tencentcloud_instance" "my_awesome_app" {
48-
instance_name = "awesome_app"
45+
resource "tencentcloud_instance" "example" {
46+
instance_name = "tf-example"
4947
availability_zone = data.tencentcloud_availability_zones.default.zones.0.name
50-
image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id
51-
instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type
48+
image_id = data.tencentcloud_images.images.images.0.image_id
49+
instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type
5250
system_disk_type = "CLOUD_PREMIUM"
5351
system_disk_size = 50
5452
hostname = "user"
5553
project_id = 0
56-
vpc_id = tencentcloud_vpc.app.id
57-
subnet_id = tencentcloud_subnet.app.id
58-
internet_max_bandwidth_out = 20
54+
vpc_id = tencentcloud_vpc.vpc.id
55+
subnet_id = tencentcloud_subnet.subnet.id
56+
internet_max_bandwidth_out = 100
5957
6058
data_disks {
6159
data_disk_type = "CLOUD_PREMIUM"
@@ -68,20 +66,20 @@ resource "tencentcloud_instance" "my_awesome_app" {
6866
}
6967
}
7068
71-
data "tencentcloud_instances" "foo" {
72-
instance_id = tencentcloud_instance.my_awesome_app.id
69+
data "tencentcloud_instances" "instances" {
70+
instance_id = tencentcloud_instance.example.id
7371
}
7472
75-
resource "tencentcloud_clb_target_group" "test" {
76-
target_group_name = "test"
77-
vpc_id = tencentcloud_vpc.app.id
73+
resource "tencentcloud_clb_target_group" "example" {
74+
target_group_name = "tf-example"
75+
vpc_id = tencentcloud_vpc.vpc.id
7876
}
7977
80-
resource "tencentcloud_clb_target_group_instance_attachment" "test" {
81-
target_group_id = tencentcloud_clb_target_group.test.id
82-
bind_ip = data.tencentcloud_instances.foo.instance_list[0].private_ip
83-
port = 222
84-
weight = 3
78+
resource "tencentcloud_clb_target_group_instance_attachment" "example" {
79+
target_group_id = tencentcloud_clb_target_group.example.id
80+
bind_ip = data.tencentcloud_instances.instances.instance_list[0].private_ip
81+
port = 8080
82+
weight = 10
8583
}
8684
```
8785

@@ -107,6 +105,6 @@ In addition to all arguments above, the following attributes are exported:
107105
CLB target group instance attachment can be imported using the id, e.g.
108106

109107
```
110-
$ terraform import tencentcloud_clb_target_group_instance_attachment.test lbtg-3k3io0i0#172.16.48.18#222
108+
$ terraform import tencentcloud_clb_target_group_instance_attachment.example lbtg-3k3io0i0#172.16.48.18#8080
111109
```
112110

0 commit comments

Comments
 (0)