Skip to content

Commit e582219

Browse files
committed
add
1 parent 9d58f67 commit e582219

File tree

3 files changed

+42
-12
lines changed

3 files changed

+42
-12
lines changed

tencentcloud/services/clb/resource_tc_clb_listener_rule.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,18 @@ func ResourceTencentCloudClbListenerRule() *schema.Resource {
4141
"domain": {
4242
Type: schema.TypeString,
4343
Optional: true,
44+
Computed: true,
4445
ConflictsWith: []string{"domains"},
45-
AtLeastOneOf: []string{"domain", "domains"},
46+
ExactlyOneOf: []string{"domain", "domains"},
4647
Description: "Domain name of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.",
4748
},
4849
"domains": {
4950
Type: schema.TypeList,
5051
Optional: true,
52+
Computed: true,
53+
ForceNew: true,
5154
ConflictsWith: []string{"domain"},
52-
AtLeastOneOf: []string{"domain", "domains"},
55+
ExactlyOneOf: []string{"domain", "domains"},
5356
Elem: &schema.Schema{Type: schema.TypeString},
5457
Description: "Domain name list of the listener rule. Single domain rules are passed to `domain`, and multi domain rules are passed to `domains`.",
5558
},

tencentcloud/services/clb/resource_tc_clb_listener_rule.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ Provides a resource to create a CLB listener rule.
44

55
Example Usage
66

7+
Create a single domain listener rule
8+
79
```hcl
8-
resource "tencentcloud_clb_listener_rule" "foo" {
10+
resource "tencentcloud_clb_listener_rule" "example" {
911
listener_id = "lbl-hh141sn9"
1012
clb_id = "lb-k2zjp9lv"
11-
domain = "foo.net"
12-
url = "/bar"
13+
domain = "example.com"
14+
url = "/"
1315
health_check_switch = true
1416
health_check_interval_time = 5
1517
health_check_health_num = 3
1618
health_check_unhealth_num = 3
1719
health_check_http_code = 2
18-
health_check_http_path = "Default Path"
19-
health_check_http_domain = "Default Domain"
20+
health_check_http_path = "/"
21+
health_check_http_domain = "check.com"
2022
health_check_http_method = "GET"
2123
certificate_ssl_mode = "MUTUAL"
2224
certificate_id = "VjANRdz8"
@@ -25,10 +27,31 @@ resource "tencentcloud_clb_listener_rule" "foo" {
2527
scheduler = "WRR"
2628
}
2729
```
30+
31+
Create a listener rule for domain lists
32+
33+
```hcl
34+
resource "tencentcloud_clb_listener_rule" "example" {
35+
listener_id = "lbl-hh141sn9"
36+
clb_id = "lb-k2zjp9lv"
37+
domains = ["example1.com", "example2.com"]
38+
url = "/"
39+
health_check_switch = true
40+
health_check_interval_time = 5
41+
health_check_health_num = 3
42+
health_check_unhealth_num = 3
43+
health_check_http_code = 2
44+
health_check_http_path = "/"
45+
health_check_http_domain = "check.com"
46+
health_check_http_method = "GET"
47+
scheduler = "WRR"
48+
}
49+
```
50+
2851
Import
2952

3053
CLB listener rule can be imported using the id (version >= 1.47.0), e.g.
3154

3255
```
33-
$ terraform import tencentcloud_clb_listener_rule.foo lb-7a0t6zqb#lbl-hh141sn9#loc-agg236ys
34-
```
56+
$ terraform import tencentcloud_clb_listener_rule.example lb-k2zjp9lv#lbl-hh141sn9#loc-agg236ys
57+
```

tencentcloud/services/clb/service_tencentcloud_clb.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,19 @@ func (me *ClbService) DescribeRuleByPara(ctx context.Context, clbId string, list
375375
findFlag = true
376376
break
377377
} else if len(domains) > 0 {
378+
tmpRef := true
378379
for i := range domains {
379380
if *domains[i] != *rule.Domains[i] {
381+
tmpRef = false
380382
break
381383
}
382384
}
383385

384-
ruleOutput = *rule
385-
findFlag = true
386-
break
386+
if tmpRef {
387+
ruleOutput = *rule
388+
findFlag = true
389+
break
390+
}
387391
}
388392
}
389393
}

0 commit comments

Comments
 (0)