Skip to content

Commit 269c83c

Browse files
authored
add listener param (#2405)
* add listener param * add changelog
1 parent ee90bc6 commit 269c83c

File tree

5 files changed

+67
-0
lines changed

5 files changed

+67
-0
lines changed

.changelog/2405.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_listener: Add parameters `health_source_ip_type`, `session_type` and `keepalive_enable`.
3+
```

tencentcloud/extension_clb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,8 @@ const (
129129
CLB_BACKEND_TYPE_CVM = "CVM"
130130
CLB_BACKEND_TYPE_ENI = "ENI"
131131
)
132+
133+
const (
134+
CLB_SESSION_TYPE_NORMAL = "NORMAL"
135+
CLB_SESSION_TYPE_QUIC = "QUIC_CID"
136+
)

tencentcloud/resource_tc_clb_listener.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ func resourceTencentCloudClbListener() *schema.Resource {
169169
"the characters of SendContext and RecvContext can only be selected in `0123456789ABCDEF` " +
170170
"and the length must be even digits.",
171171
},
172+
"health_source_ip_type": {
173+
Type: schema.TypeInt,
174+
Optional: true,
175+
Computed: true,
176+
ValidateFunc: validateAllowedIntValue([]int{0, 1}),
177+
Description: "Specifies the type of health check source IP. `0` (default): CLB VIP. `1`: 100.64 IP range.",
178+
},
172179
"certificate_ssl_mode": {
173180
Type: schema.TypeString,
174181
Optional: true,
@@ -211,6 +218,19 @@ func resourceTencentCloudClbListener() *schema.Resource {
211218
ValidateFunc: validateAllowedStringValue([]string{CLB_TARGET_TYPE_NODE, CLB_TARGET_TYPE_TARGETGROUP}),
212219
Description: "Backend target type. Valid values: `NODE`, `TARGETGROUP`. `NODE` means to bind ordinary nodes, `TARGETGROUP` means to bind target group. NOTES: TCP/UDP/TCP_SSL listener must configuration, HTTP/HTTPS listener needs to be configured in tencentcloud_clb_listener_rule.",
213220
},
221+
"session_type": {
222+
Type: schema.TypeString,
223+
Optional: true,
224+
Computed: true,
225+
ValidateFunc: validateAllowedStringValue([]string{CLB_SESSION_TYPE_NORMAL, CLB_SESSION_TYPE_QUIC}),
226+
Description: "Session persistence type. Valid values: `NORMAL`: the default session persistence type; `QUIC_CID`: session persistence by QUIC connection ID. The `QUIC_CID` value can only be configured in UDP listeners. If this field is not specified, the default session persistence type will be used.",
227+
},
228+
"keepalive_enable": {
229+
Type: schema.TypeInt,
230+
Computed: true,
231+
Optional: true,
232+
Description: "Whether to enable a persistent connection. This parameter is applicable only to HTTP and HTTPS listeners. Valid values: 0 (disable; default value) and 1 (enable).",
233+
},
214234
"end_port": {
215235
Type: schema.TypeInt,
216236
ForceNew: true,
@@ -313,6 +333,15 @@ func resourceTencentCloudClbListenerCreate(d *schema.ResourceData, meta interfac
313333
request.SniSwitch = &vvv
314334
}
315335
}
336+
337+
if v, ok := d.GetOk("session_type"); ok {
338+
request.SessionType = helper.String(v.(string))
339+
}
340+
341+
if v, ok := d.GetOkExists("keepalive_enable"); ok {
342+
request.KeepaliveEnable = helper.IntInt64(v.(int))
343+
}
344+
316345
if v, ok := d.GetOkExists("end_port"); ok {
317346
request.EndPort = helper.IntUint64(v.(int))
318347
}
@@ -461,6 +490,9 @@ func resourceTencentCloudClbListenerRead(d *schema.ResourceData, meta interface{
461490
if instance.HealthCheck.RecvContext != nil {
462491
_ = d.Set("health_check_recv_context", instance.HealthCheck.RecvContext)
463492
}
493+
if instance.HealthCheck.SourceIpType != nil {
494+
_ = d.Set("health_source_ip_type", instance.HealthCheck.SourceIpType)
495+
}
464496
}
465497

466498
if instance.Certificate != nil {
@@ -471,6 +503,13 @@ func resourceTencentCloudClbListenerRead(d *schema.ResourceData, meta interface{
471503
}
472504
}
473505

506+
if instance.SessionType != nil {
507+
_ = d.Set("session_type", instance.SessionType)
508+
}
509+
if instance.KeepaliveEnable != nil {
510+
_ = d.Set("keepalive_enable", instance.KeepaliveEnable)
511+
}
512+
474513
if instance.EndPort != nil {
475514
_ = d.Set("end_port", instance.EndPort)
476515
}
@@ -556,6 +595,18 @@ func resourceTencentCloudClbListenerUpdate(d *schema.ResourceData, meta interfac
556595
request.TargetType = helper.String(targetType)
557596
}
558597

598+
if d.HasChange("session_type") {
599+
changed = true
600+
sessionType := d.Get("session_type").(string)
601+
request.SessionType = helper.String(sessionType)
602+
}
603+
604+
if d.HasChange("keepalive_enable") {
605+
changed = true
606+
keepaliveEnable := d.Get("keepalive_enable").(int)
607+
request.KeepaliveEnable = helper.IntInt64(keepaliveEnable)
608+
}
609+
559610
if changed {
560611
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
561612
response, e := meta.(*TencentCloudClient).apiV3Conn.UseClbClient().ModifyListener(request)

tencentcloud/service_tencentcloud_clb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,11 @@ func checkHealthCheckPara(ctx context.Context, d *schema.ResourceData, protocol
898898
healthCheck.RecvContext = helper.String(v.(string))
899899
}
900900

901+
if v, ok := d.GetOk("health_source_ip_type"); ok {
902+
healthSetFlag = true
903+
healthCheck.SourceIpType = helper.Int64(int64(v.(int)))
904+
}
905+
901906
if healthSetFlag {
902907
if !(((protocol == CLB_LISTENER_PROTOCOL_TCP || protocol == CLB_LISTENER_PROTOCOL_UDP ||
903908
protocol == CLB_LISTENER_PROTOCOL_TCPSSL || protocol == CLB_LISTENER_PROTOCOL_QUIC) &&

website/docs/r/clb_listener.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,12 @@ The following arguments are supported:
196196
* `health_check_time_out` - (Optional, Int) Response timeout of health check. Valid value ranges: [2~60] sec. Default is 2 sec. Response timeout needs to be less than check interval. NOTES: Only supports listeners of `TCP`,`UDP`,`TCP_SSL` protocol.
197197
* `health_check_type` - (Optional, String) Protocol used for health check. Valid values: `CUSTOM`, `TCP`, `HTTP`.
198198
* `health_check_unhealth_num` - (Optional, Int) Unhealthy threshold of health check, and the default is `3`. If a success result is returned for the health check 3 consecutive times, the CVM is identified as unhealthy. 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`.
199+
* `health_source_ip_type` - (Optional, Int) Specifies the type of health check source IP. `0` (default): CLB VIP. `1`: 100.64 IP range.
200+
* `keepalive_enable` - (Optional, Int) Whether to enable a persistent connection. This parameter is applicable only to HTTP and HTTPS listeners. Valid values: 0 (disable; default value) and 1 (enable).
199201
* `port` - (Optional, Int, ForceNew) Port of the CLB listener.
200202
* `scheduler` - (Optional, String) Scheduling method of the CLB listener, and available values are 'WRR' and 'LEAST_CONN'. The default is 'WRR'. NOTES: The listener of `HTTP` and `HTTPS` protocol additionally supports the `IP Hash` method. NOTES: TCP/UDP/TCP_SSL listener allows direct configuration, HTTP/HTTPS listener needs to be configured in `tencentcloud_clb_listener_rule`.
201203
* `session_expire_time` - (Optional, Int) Time of session persistence within the CLB listener. NOTES: Available when scheduler is specified as `WRR`, and not available when listener protocol is `TCP_SSL`. NOTES: TCP/UDP/TCP_SSL listener allows direct configuration, HTTP/HTTPS listener needs to be configured in `tencentcloud_clb_listener_rule`.
204+
* `session_type` - (Optional, String) Session persistence type. Valid values: `NORMAL`: the default session persistence type; `QUIC_CID`: session persistence by QUIC connection ID. The `QUIC_CID` value can only be configured in UDP listeners. If this field is not specified, the default session persistence type will be used.
202205
* `sni_switch` - (Optional, Bool, ForceNew) Indicates whether SNI is enabled, and only supported with protocol `HTTPS`. If enabled, you can set a certificate for each rule in `tencentcloud_clb_listener_rule`, otherwise all rules have a certificate.
203206
* `target_type` - (Optional, String) Backend target type. Valid values: `NODE`, `TARGETGROUP`. `NODE` means to bind ordinary nodes, `TARGETGROUP` means to bind target group. NOTES: TCP/UDP/TCP_SSL listener must configuration, HTTP/HTTPS listener needs to be configured in tencentcloud_clb_listener_rule.
204207

0 commit comments

Comments
 (0)