Skip to content

Commit b592fa4

Browse files
committed
add
1 parent 784954e commit b592fa4

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

tencentcloud/services/clb/resource_tc_clb_listener_rule.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func ResourceTencentCloudClbListenerRule() *schema.Resource {
5151
Type: schema.TypeSet,
5252
Optional: true,
5353
Computed: true,
54-
ForceNew: true,
5554
ConflictsWith: []string{"domain"},
5655
ExactlyOneOf: []string{"domain", "domains"},
5756
Elem: &schema.Schema{Type: schema.TypeString},
@@ -731,6 +730,24 @@ func resourceTencentCloudClbListenerRuleUpdate(d *schema.ResourceData, meta inte
731730
domainChanged = true
732731
domainRequest.Domain = helper.String(old.(string))
733732
domainRequest.NewDomain = helper.String(new.(string))
733+
} else if d.HasChange("domains") {
734+
old, new := d.GetChange("domains")
735+
domainChanged = true
736+
oldDomains := old.(*schema.Set).List()
737+
newDomains := new.(*schema.Set).List()
738+
739+
if len(oldDomains) < 1 || len(newDomains) < 1 {
740+
return fmt.Errorf("Params `domains` cant not be empty.")
741+
}
742+
743+
domainRequest.Domain = helper.String(oldDomains[0].(string))
744+
tmpDomains := make([]*string, 0, len(newDomains))
745+
for _, value := range newDomains {
746+
domain := value.(string)
747+
tmpDomains = append(tmpDomains, &domain)
748+
}
749+
750+
domainRequest.NewDomains = tmpDomains
734751
} else {
735752
domainRequest.Domain = helper.String(d.Get("domain").(string))
736753
}
@@ -778,7 +795,7 @@ func resourceTencentCloudClbListenerRuleUpdate(d *schema.ResourceData, meta inte
778795
return tccommon.RetryError(e)
779796
} else {
780797
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
781-
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
798+
logId, domainRequest.GetAction(), domainRequest.ToJsonString(), response.ToJsonString())
782799
if response == nil || response.Response == nil || response.Response.RequestId == nil {
783800
return resource.NonRetryableError(fmt.Errorf("Modify domain attributes failed, Response is nil."))
784801
}

tencentcloud/services/clb/resource_tc_clb_listener_rule.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ Create a listener rule for domain lists
3232

3333
```hcl
3434
resource "tencentcloud_clb_listener_rule" "example" {
35-
listener_id = "lbl-hh141sn9"
36-
clb_id = "lb-k2zjp9lv"
35+
listener_id = "lbl-2qzcv7oq"
36+
clb_id = "lb-l6cp6jt4"
3737
domains = ["example1.com", "example2.com"]
3838
url = "/"
3939
health_check_switch = true
4040
health_check_interval_time = 5
4141
health_check_health_num = 3
4242
health_check_unhealth_num = 3
43-
health_check_http_code = 2
43+
health_check_port = 8080
44+
health_check_time_out = 2
45+
health_check_http_code = 15
46+
health_check_type = "HTTP"
4447
health_check_http_path = "/"
4548
health_check_http_domain = "check.com"
4649
health_check_http_method = "GET"

website/docs/r/clb_listener_rule.html.markdown

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@ resource "tencentcloud_clb_listener_rule" "example" {
4343

4444
```hcl
4545
resource "tencentcloud_clb_listener_rule" "example" {
46-
listener_id = "lbl-hh141sn9"
47-
clb_id = "lb-k2zjp9lv"
46+
listener_id = "lbl-2qzcv7oq"
47+
clb_id = "lb-l6cp6jt4"
4848
domains = ["example1.com", "example2.com"]
4949
url = "/"
5050
health_check_switch = true
5151
health_check_interval_time = 5
5252
health_check_health_num = 3
5353
health_check_unhealth_num = 3
54-
health_check_http_code = 2
54+
health_check_port = 8080
55+
health_check_time_out = 2
56+
health_check_http_code = 15
57+
health_check_type = "HTTP"
5558
health_check_http_path = "/"
5659
health_check_http_domain = "check.com"
5760
health_check_http_method = "GET"
@@ -70,7 +73,7 @@ The following arguments are supported:
7073
* `certificate_id` - (Optional, String) ID of the server certificate. NOTES: Only supports listeners of HTTPS protocol.
7174
* `certificate_ssl_mode` - (Optional, String, ForceNew) Type of certificate. Valid values: `UNIDIRECTIONAL`, `MUTUAL`. NOTES: Only supports listeners of HTTPS protocol.
7275
* `domain` - (Optional, String) Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
73-
* `domains` - (Optional, Set: [`String`], ForceNew) Domain name list of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
76+
* `domains` - (Optional, Set: [`String`]) Domain name list of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.
7477
* `forward_type` - (Optional, String) Forwarding protocol between the CLB instance and real server. Valid values: `HTTP`, `HTTPS`, `GRPC`, `GRPCS`, `TRPC`. The default is `HTTP`.
7578
* `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 3 consecutive times, indicates that the forwarding is normal. 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`.
7679
* `health_check_http_code` - (Optional, Int) HTTP Status Code. The default is 31. Valid value ranges: [1~31]. `1 means the return value '1xx' is health. `2` means the return value '2xx' is health. `4` means the return value '3xx' is health. `8` means the return value '4xx' is health. 16 means the return value '5xx' is health. If you want multiple return codes to indicate health, need to add the corresponding values. NOTES: The 'HTTP' health check of the 'TCP' listener only supports specifying one health check status code. NOTES: Only supports listeners of 'HTTP' and 'HTTPS' protocol.

0 commit comments

Comments
 (0)