Skip to content

Commit d9de732

Browse files
author
ivan
committed
添加Update操作对Port的支持
1 parent c34706f commit d9de732

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

tencentcloud/resource_tc_clb_target_group.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func resourceTencentCloudClbTargetCreate(d *schema.ResourceData, meta interface{
106106
err error
107107
)
108108

109-
if v, ok := d.GetOk("target_group_instance"); ok {
109+
if v, ok := d.GetOk("target_group_instances"); ok {
110110
targetGroupInstances := v.([]interface{})
111111
for _, v1 := range targetGroupInstances {
112112
value := v1.(map[string]interface{})
@@ -168,15 +168,28 @@ func resourceTencentCloudClbTargetUpdate(d *schema.ResourceData, meta interface{
168168
ctx = context.WithValue(context.TODO(), logIdKey, logId)
169169
clbService = ClbService{client: meta.(*TencentCloudClient).apiV3Conn}
170170
targetGroupId = d.Id()
171+
port uint64
172+
tgtGroupName string
171173
)
172174

175+
isChanged := false
176+
if d.HasChange("port") {
177+
isChanged = true
178+
port = uint64(d.Get("port").(int))
179+
}
180+
173181
if d.HasChange("target_group_name") {
174-
targetGroupName := d.Get("target_group_name").(string)
175-
err := clbService.ModifyTargetGroup(ctx, targetGroupId, targetGroupName)
182+
isChanged = true
183+
tgtGroupName = d.Get("target_group_name").(string)
184+
}
185+
186+
if isChanged {
187+
err := clbService.ModifyTargetGroup(ctx, targetGroupId, tgtGroupName, port)
176188
if err != nil {
177189
return err
178190
}
179191
}
192+
180193
return resourceTencentCloudClbTargetRead(d, meta)
181194
}
182195

tencentcloud/service_tencentcloud_clb.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,11 @@ func (me *ClbService) CreateTargetGroup(ctx context.Context, targetGroupName str
10551055
return
10561056
}
10571057

1058-
func (me *ClbService) ModifyTargetGroup(ctx context.Context, targetGroupId string, targetGroupName string) (err error) {
1058+
func (me *ClbService) ModifyTargetGroup(ctx context.Context, targetGroupId, targetGroupName string, port uint64) (err error) {
10591059
request := clb.NewModifyTargetGroupAttributeRequest()
10601060
request.TargetGroupId = &targetGroupId
10611061
request.TargetGroupName = &targetGroupName
1062+
request.Port = &port
10621063

10631064
err = resource.Retry(writeRetryTimeout, func() *resource.RetryError {
10641065
_, err := me.client.UseClbClient().ModifyTargetGroupAttribute(request)

0 commit comments

Comments
 (0)