Skip to content

Commit fd06631

Browse files
committed
support end port
1 parent f9bf320 commit fd06631

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

tencentcloud/resource_tc_clb_listener.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,27 @@ resource "tencentcloud_clb_listener" "TCPSSL_listener" {
136136
target_type = "TARGETGROUP"
137137
}
138138
```
139+
140+
Port Range Listener
141+
142+
```hcl
143+
resource "tencentcloud_clb_instance" "clb_basic" {
144+
network_type = "OPEN"
145+
clb_name = "tf-listener-test"
146+
}
147+
148+
resource "tencentcloud_clb_listener" "listener_basic" {
149+
clb_id = tencentcloud_clb_instance.clb_basic.id
150+
port = 1
151+
end_port = 6
152+
protocol = "TCP"
153+
listener_name = "listener_basic"
154+
session_expire_time = 30
155+
scheduler = "WRR"
156+
target_type = "NODE"
157+
}
158+
```
159+
139160
Import
140161
141162
CLB listener can be imported using the id (version >= 1.47.0), e.g.
@@ -357,6 +378,13 @@ func resourceTencentCloudClbListener() *schema.Resource {
357378
ValidateFunc: validateAllowedStringValue([]string{CLB_TARGET_TYPE_NODE, CLB_TARGET_TYPE_TARGETGROUP}),
358379
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.",
359380
},
381+
"end_port": {
382+
Type: schema.TypeInt,
383+
ForceNew: true,
384+
Computed: true,
385+
Optional: true,
386+
Description: "This parameter is used to specify the end port and is required when creating a port range listener. Only one member can be passed in when inputting the `Ports` parameter, which is used to specify the start port. If you want to try the port range feature, please [submit a ticket](https://console.cloud.tencent.com/workorder/category).",
387+
},
360388
//computed
361389
"listener_id": {
362390
Type: schema.TypeString,
@@ -452,6 +480,10 @@ func resourceTencentCloudClbListenerCreate(d *schema.ResourceData, meta interfac
452480
request.SniSwitch = &vvv
453481
}
454482
}
483+
if v, ok := d.GetOkExists("end_port"); ok {
484+
request.EndPort = helper.IntUint64(v.(int))
485+
}
486+
455487
var response *clb.CreateListenerResponse
456488
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
457489
result, e := meta.(*TencentCloudClient).apiV3Conn.UseClbClient().CreateListener(request)
@@ -606,6 +638,10 @@ func resourceTencentCloudClbListenerRead(d *schema.ResourceData, meta interface{
606638
}
607639
}
608640

641+
if instance.EndPort != nil {
642+
_ = d.Set("end_port", instance.EndPort)
643+
}
644+
609645
return nil
610646
}
611647

website/docs/r/clb_listener.html.markdown

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ resource "tencentcloud_clb_listener" "TCPSSL_listener" {
150150
}
151151
```
152152

153+
### Port Range Listener
154+
155+
```hcl
156+
resource "tencentcloud_clb_instance" "clb_basic" {
157+
network_type = "OPEN"
158+
clb_name = "tf-listener-test"
159+
}
160+
161+
resource "tencentcloud_clb_listener" "listener_basic" {
162+
clb_id = tencentcloud_clb_instance.clb_basic.id
163+
port = 1
164+
end_port = 6
165+
protocol = "TCP"
166+
listener_name = "listener_basic"
167+
session_expire_time = 30
168+
scheduler = "WRR"
169+
target_type = "NODE"
170+
}
171+
```
172+
153173
## Argument Reference
154174

155175
The following arguments are supported:
@@ -160,6 +180,7 @@ The following arguments are supported:
160180
* `certificate_ca_id` - (Optional, String) ID of the client certificate. NOTES: Only supports listeners of `HTTPS` and `TCP_SSL` protocol and must be set when the ssl mode is `MUTUAL`.
161181
* `certificate_id` - (Optional, String) ID of the server certificate. NOTES: Only supports listeners of `HTTPS` and `TCP_SSL` protocol and must be set when it is available.
162182
* `certificate_ssl_mode` - (Optional, String) Type of certificate. Valid values: `UNIDIRECTIONAL`, `MUTUAL`. NOTES: Only supports listeners of `HTTPS` and `TCP_SSL` protocol and must be set when it is available.
183+
* `end_port` - (Optional, Int, ForceNew) This parameter is used to specify the end port and is required when creating a port range listener. Only one member can be passed in when inputting the `Ports` parameter, which is used to specify the start port. If you want to try the port range feature, please [submit a ticket](https://console.cloud.tencent.com/workorder/category).
163184
* `health_check_context_type` - (Optional, String) Health check protocol. When the value of `health_check_type` of the health check protocol is `CUSTOM`, this field is required, which represents the input format of the health check. Valid values: `HEX`, `TEXT`.
164185
* `health_check_health_num` - (Optional, Int) Health threshold of health check, and the default is `3`. If a success result is returned for the health check for 3 consecutive times, the backend CVM is identified as healthy. 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.
165186
* `health_check_http_code` - (Optional, Int) HTTP health check code of TCP listener, Valid value ranges: [1~31]. When the value of `health_check_type` of the health check protocol is `HTTP`, this field is required. Valid values: `1`, `2`, `4`, `8`, `16`. `1` means http_1xx, `2` means http_2xx, `4` means http_3xx, `8` means http_4xx, `16` means http_5xx.If you want multiple return codes to indicate health, need to add the corresponding values.

0 commit comments

Comments
 (0)