diff --git a/.changelog/3079.txt b/.changelog/3079.txt new file mode 100644 index 000000000..79be07926 --- /dev/null +++ b/.changelog/3079.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_clb_listener_rule: params `domains` support modify +``` diff --git a/tencentcloud/services/clb/resource_tc_clb_listener_rule.go b/tencentcloud/services/clb/resource_tc_clb_listener_rule.go index c5bb6de78..b40a72963 100644 --- a/tencentcloud/services/clb/resource_tc_clb_listener_rule.go +++ b/tencentcloud/services/clb/resource_tc_clb_listener_rule.go @@ -51,7 +51,6 @@ func ResourceTencentCloudClbListenerRule() *schema.Resource { Type: schema.TypeSet, Optional: true, Computed: true, - ForceNew: true, ConflictsWith: []string{"domain"}, ExactlyOneOf: []string{"domain", "domains"}, Elem: &schema.Schema{Type: schema.TypeString}, @@ -731,6 +730,24 @@ func resourceTencentCloudClbListenerRuleUpdate(d *schema.ResourceData, meta inte domainChanged = true domainRequest.Domain = helper.String(old.(string)) domainRequest.NewDomain = helper.String(new.(string)) + } else if d.HasChange("domains") { + old, new := d.GetChange("domains") + domainChanged = true + oldDomains := old.(*schema.Set).List() + newDomains := new.(*schema.Set).List() + + if len(oldDomains) < 1 || len(newDomains) < 1 { + return fmt.Errorf("Params `domains` cant not be empty.") + } + + domainRequest.Domain = helper.String(oldDomains[0].(string)) + tmpDomains := make([]*string, 0, len(newDomains)) + for _, value := range newDomains { + domain := value.(string) + tmpDomains = append(tmpDomains, &domain) + } + + domainRequest.NewDomains = tmpDomains } else { domainRequest.Domain = helper.String(d.Get("domain").(string)) } @@ -778,7 +795,7 @@ func resourceTencentCloudClbListenerRuleUpdate(d *schema.ResourceData, meta inte return tccommon.RetryError(e) } else { log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", - logId, request.GetAction(), request.ToJsonString(), response.ToJsonString()) + logId, domainRequest.GetAction(), domainRequest.ToJsonString(), response.ToJsonString()) if response == nil || response.Response == nil || response.Response.RequestId == nil { return resource.NonRetryableError(fmt.Errorf("Modify domain attributes failed, Response is nil.")) } diff --git a/tencentcloud/services/clb/resource_tc_clb_listener_rule.md b/tencentcloud/services/clb/resource_tc_clb_listener_rule.md index cc6370f6f..bca927ffd 100644 --- a/tencentcloud/services/clb/resource_tc_clb_listener_rule.md +++ b/tencentcloud/services/clb/resource_tc_clb_listener_rule.md @@ -32,15 +32,18 @@ Create a listener rule for domain lists ```hcl resource "tencentcloud_clb_listener_rule" "example" { - listener_id = "lbl-hh141sn9" - clb_id = "lb-k2zjp9lv" + listener_id = "lbl-2qzcv7oq" + clb_id = "lb-l6cp6jt4" domains = ["example1.com", "example2.com"] url = "/" health_check_switch = true health_check_interval_time = 5 health_check_health_num = 3 health_check_unhealth_num = 3 - health_check_http_code = 2 + health_check_port = 8080 + health_check_time_out = 2 + health_check_http_code = 15 + health_check_type = "HTTP" health_check_http_path = "/" health_check_http_domain = "check.com" health_check_http_method = "GET" diff --git a/website/docs/r/clb_listener_rule.html.markdown b/website/docs/r/clb_listener_rule.html.markdown index 69fb3572c..f7ab9e0fa 100644 --- a/website/docs/r/clb_listener_rule.html.markdown +++ b/website/docs/r/clb_listener_rule.html.markdown @@ -43,15 +43,18 @@ resource "tencentcloud_clb_listener_rule" "example" { ```hcl resource "tencentcloud_clb_listener_rule" "example" { - listener_id = "lbl-hh141sn9" - clb_id = "lb-k2zjp9lv" + listener_id = "lbl-2qzcv7oq" + clb_id = "lb-l6cp6jt4" domains = ["example1.com", "example2.com"] url = "/" health_check_switch = true health_check_interval_time = 5 health_check_health_num = 3 health_check_unhealth_num = 3 - health_check_http_code = 2 + health_check_port = 8080 + health_check_time_out = 2 + health_check_http_code = 15 + health_check_type = "HTTP" health_check_http_path = "/" health_check_http_domain = "check.com" health_check_http_method = "GET" @@ -70,7 +73,7 @@ The following arguments are supported: * `certificate_id` - (Optional, String) ID of the server certificate. NOTES: Only supports listeners of HTTPS protocol. * `certificate_ssl_mode` - (Optional, String, ForceNew) Type of certificate. Valid values: `UNIDIRECTIONAL`, `MUTUAL`. NOTES: Only supports listeners of HTTPS protocol. * `domain` - (Optional, String) Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`. -* `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`. +* `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`. * `forward_type` - (Optional, String) Forwarding protocol between the CLB instance and real server. Valid values: `HTTP`, `HTTPS`, `GRPC`, `GRPCS`, `TRPC`. The default is `HTTP`. * `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`. * `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.