Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(clb): [121662199] tencentcloud_clb_listener_rule params domains support modify #3079

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3079.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_clb_listener_rule: params `domains` support modify
```
21 changes: 19 additions & 2 deletions tencentcloud/services/clb/resource_tc_clb_listener_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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."))
}
Expand Down
9 changes: 6 additions & 3 deletions tencentcloud/services/clb/resource_tc_clb_listener_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions website/docs/r/clb_listener_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down
Loading