Skip to content

Commit 41c215e

Browse files
committed
add
1 parent bf45548 commit 41c215e

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

tencentcloud/services/clb/resource_tc_clb_listener_rule.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ func ResourceTencentCloudClbListenerRule() *schema.Resource {
8989
ValidateFunc: tccommon.ValidateIntegerInRange(2, 10),
9090
Description: "Unhealthy threshold of health check, and the default is `3`. If the unhealthy result is returned 3 consecutive times, indicates that the forwarding is abnormal. The value range is [2-10]. NOTES: TCP/UDP/TCP_SSL listener allows direct configuration, HTTP/HTTPS listener needs to be configured in `tencentcloud_clb_listener_rule`.",
9191
},
92+
"health_check_port": {
93+
Type: schema.TypeInt,
94+
Optional: true,
95+
Computed: true,
96+
Description: "Customize detection related parameters. Health check port, defaults to the port of the backend service, unless you want to specify a specific port, it is recommended to leave it blank. (Applicable only to TCP/UDP listeners).",
97+
},
9298
"health_check_type": {
9399
Type: schema.TypeString,
94100
Optional: true,
@@ -299,7 +305,7 @@ func resourceTencentCloudClbListenerRuleCreate(d *schema.ResourceData, meta inte
299305
rule.Scheduler = helper.String(scheduler)
300306
}
301307

302-
if v, ok := d.GetOk("session_expire_time"); ok {
308+
if v, ok := d.GetOkExists("session_expire_time"); ok {
303309
if !(protocol == CLB_LISTENER_PROTOCOL_HTTP || protocol == CLB_LISTENER_PROTOCOL_HTTPS) {
304310
return fmt.Errorf("[CHECK][CLB listener rule][Create] check: session_expire_time can only be set with protocol TCP/UDP or rule of listener HTTP/HTTPS")
305311
}
@@ -368,6 +374,11 @@ func resourceTencentCloudClbListenerRuleCreate(d *schema.ResourceData, meta inte
368374
if ruleErr != nil {
369375
return tccommon.RetryError(errors.WithStack(ruleErr))
370376
}
377+
378+
if ruleInstance == nil || ruleInstance.LocationId == nil {
379+
return resource.NonRetryableError(fmt.Errorf("read CLB listener rule failed, Response is nil."))
380+
}
381+
371382
locationId = *ruleInstance.LocationId
372383
return nil
373384
})
@@ -377,7 +388,7 @@ func resourceTencentCloudClbListenerRuleCreate(d *schema.ResourceData, meta inte
377388
}
378389

379390
//this ID style changes since terraform 1.47.0
380-
d.SetId(clbId + tccommon.FILED_SP + listenerId + tccommon.FILED_SP + locationId)
391+
d.SetId(strings.Join([]string{clbId, listenerId, locationId}, tccommon.FILED_SP))
381392

382393
// set http2
383394
if v, ok := d.GetOkExists("http2_switch"); ok {
@@ -559,6 +570,7 @@ func resourceTencentCloudClbListenerRuleRead(d *schema.ResourceData, meta interf
559570
_ = d.Set("health_check_http_domain", instance.HealthCheck.HttpCheckDomain)
560571
_ = d.Set("health_check_http_path", instance.HealthCheck.HttpCheckPath)
561572
_ = d.Set("health_check_http_code", instance.HealthCheck.HttpCode)
573+
_ = d.Set("health_check_port", instance.HealthCheck.CheckPort)
562574
_ = d.Set("health_check_type", instance.HealthCheck.CheckType)
563575
_ = d.Set("health_check_time_out", instance.HealthCheck.TimeOut)
564576
}

tencentcloud/services/clb/service_tencentcloud_clb.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -863,27 +863,27 @@ func checkHealthCheckPara(ctx context.Context, d *schema.ResourceData, protocol
863863
healthCheck.HealthSwitch = &healthSwitch
864864
}
865865
if IsHealthCheckEnable(healthSwitch) {
866-
if v, ok := d.GetOk("health_check_time_out"); ok {
866+
if v, ok := d.GetOkExists("health_check_time_out"); ok {
867867
healthSetFlag = true
868868
vv := int64(v.(int))
869869
healthCheck.TimeOut = &vv
870870
}
871-
if v, ok := d.GetOk("health_check_interval_time"); ok {
871+
if v, ok := d.GetOkExists("health_check_interval_time"); ok {
872872
healthSetFlag = true
873873
vv := int64(v.(int))
874874
healthCheck.IntervalTime = &vv
875875
}
876-
if v, ok := d.GetOk("health_check_health_num"); ok {
876+
if v, ok := d.GetOkExists("health_check_health_num"); ok {
877877
healthSetFlag = true
878878
vv := int64(v.(int))
879879
healthCheck.HealthNum = &vv
880880
}
881-
if v, ok := d.GetOk("health_check_unhealth_num"); ok {
881+
if v, ok := d.GetOkExists("health_check_unhealth_num"); ok {
882882
healthSetFlag = true
883883
vv := int64(v.(int))
884884
healthCheck.UnHealthNum = &vv
885885
}
886-
if v, ok := d.GetOk("health_check_port"); ok {
886+
if v, ok := d.GetOkExists("health_check_port"); ok {
887887
healthSetFlag = true
888888
healthCheck.CheckPort = helper.Int64(int64(v.(int)))
889889
}
@@ -893,7 +893,7 @@ func checkHealthCheckPara(ctx context.Context, d *schema.ResourceData, protocol
893893
checkType = v.(string)
894894
healthCheck.CheckType = &checkType
895895
}
896-
if v, ok := d.GetOk("health_check_http_code"); ok {
896+
if v, ok := d.GetOkExists("health_check_http_code"); ok {
897897
if !(protocol == CLB_LISTENER_PROTOCOL_HTTP || protocol == CLB_LISTENER_PROTOCOL_HTTPS ||
898898
(protocol == CLB_LISTENER_PROTOCOL_TCP && checkType == HEALTH_CHECK_TYPE_HTTP)) {
899899
healthSetFlag = false
@@ -978,7 +978,7 @@ func checkHealthCheckPara(ctx context.Context, d *schema.ResourceData, protocol
978978
healthCheck.RecvContext = helper.String(v.(string))
979979
}
980980

981-
if v, ok := d.GetOk("health_source_ip_type"); ok {
981+
if v, ok := d.GetOkExists("health_source_ip_type"); ok {
982982
healthSetFlag = true
983983
healthCheck.SourceIpType = helper.Int64(int64(v.(int)))
984984
}

website/docs/r/clb_listener_rule.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The following arguments are supported:
7878
* `health_check_http_method` - (Optional, String) Methods of health check. NOTES: Only supports listeners of `HTTP` and `HTTPS` protocol. The default is `HEAD`, the available value are `HEAD` and `GET`.
7979
* `health_check_http_path` - (Optional, String) Path of health check. NOTES: Only supports listeners of `HTTP` and `HTTPS` protocol.
8080
* `health_check_interval_time` - (Optional, Int) Interval time of health check. Valid value ranges: (2~300) sec. and the default is `5` sec. NOTES: TCP/UDP/TCP_SSL listener allows direct configuration, HTTP/HTTPS listener needs to be configured in `tencentcloud_clb_listener_rule`.
81+
* `health_check_port` - (Optional, Int) Customize detection related parameters. Health check port, defaults to the port of the backend service, unless you want to specify a specific port, it is recommended to leave it blank. (Applicable only to TCP/UDP listeners).
8182
* `health_check_switch` - (Optional, Bool) Indicates whether health check is enabled.
8283
* `health_check_time_out` - (Optional, Int) Time out of health check. The value range is [2-60](SEC).
8384
* `health_check_type` - (Optional, String) Type of health check. Valid value is `CUSTOM`, `PING`, `TCP`, `HTTP`, `HTTPS`, `GRPC`, `GRPCS`.

0 commit comments

Comments
 (0)