Skip to content

Commit 0336560

Browse files
tongyimingmikatong
and
mikatong
authored
fix(teo): [123732420] support teo l7 rule v2 (#3376)
* support tencentcloud_teo_l7_acc_rule_v2 and tencentcloud_teo_l7_acc_rule_priority_operation * add changelog --------- Co-authored-by: mikatong <[email protected]>
1 parent 8be2ba3 commit 0336560

14 files changed

+1535
-2
lines changed

.changelog/3376.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:new-resource
2+
tencentcloud_teo_l7_acc_rule_v2
3+
```
4+
5+
```release-note:new-resource
6+
tencentcloud_teo_l7_acc_rule_priority_operation
7+
```

tencentcloud/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,6 +1855,8 @@ func Provider() *schema.Provider {
18551855
"tencentcloud_teo_l4_proxy": teo.ResourceTencentCloudTeoL4Proxy(),
18561856
"tencentcloud_teo_l4_proxy_rule": teo.ResourceTencentCloudTeoL4ProxyRule(),
18571857
"tencentcloud_teo_l7_acc_rule": teo.ResourceTencentCloudTeoL7AccRule(),
1858+
"tencentcloud_teo_l7_acc_rule_v2": teo.ResourceTencentCloudTeoL7AccRuleV2(),
1859+
"tencentcloud_teo_l7_acc_rule_priority_operation": teo.ResourceTencentCloudTeoL7AccRulePriorityOperation(),
18581860
"tencentcloud_teo_l7_acc_setting": teo.ResourceTencentCloudTeoL7AccSetting(),
18591861
"tencentcloud_teo_rule_engine": teo.ResourceTencentCloudTeoRuleEngine(),
18601862
"tencentcloud_teo_ownership_verify": teo.ResourceTencentCloudTeoOwnershipVerify(),

tencentcloud/provider.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,8 @@ tencentcloud_teo_function_rule
15051505
tencentcloud_teo_function_rule_priority
15061506
tencentcloud_teo_function_runtime_environment
15071507
tencentcloud_teo_l7_acc_rule
1508+
tencentcloud_teo_l7_acc_rule_v2
1509+
tencentcloud_teo_l7_acc_rule_priority_operation
15081510
tencentcloud_teo_l7_acc_setting
15091511
tencentcloud_teo_security_ip_group
15101512
tencentcloud_teo_security_policy_config

tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package teo
2+
3+
import (
4+
"log"
5+
6+
teov20220901 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
7+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
8+
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
9+
10+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
11+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12+
)
13+
14+
func ResourceTencentCloudTeoL7AccRulePriorityOperation() *schema.Resource {
15+
return &schema.Resource{
16+
Create: resourceTencentCloudTeoL7AccRulePriorityOperationCreate,
17+
Read: resourceTencentCloudTeoL7AccRulePriorityOperationRead,
18+
Delete: resourceTencentCloudTeoL7AccRulePriorityOperationDelete,
19+
Schema: map[string]*schema.Schema{
20+
"zone_id": {
21+
Type: schema.TypeString,
22+
Required: true,
23+
ForceNew: true,
24+
Description: "Zone id.",
25+
},
26+
"rule_ids": {
27+
Type: schema.TypeList,
28+
Required: true,
29+
ForceNew: true,
30+
Description: "Complete list of rule IDs under site ID.",
31+
Elem: &schema.Schema{
32+
Type: schema.TypeString,
33+
},
34+
},
35+
},
36+
}
37+
}
38+
39+
func resourceTencentCloudTeoL7AccRulePriorityOperationCreate(d *schema.ResourceData, meta interface{}) error {
40+
defer tccommon.LogElapsed("resource.tencentcloud_teo_l7_acc_rule_priority_operation.create")()
41+
defer tccommon.InconsistentCheck(d, meta)()
42+
43+
logId := tccommon.GetLogId(tccommon.ContextNil)
44+
45+
request := teov20220901.NewModifyL7AccRulePriorityRequest()
46+
zoneId := d.Get("zone_id").(string)
47+
request.ZoneId = helper.String(zoneId)
48+
ruleIds := d.Get("rule_ids").([]interface{})
49+
for _, ruleId := range ruleIds {
50+
request.RuleIds = append(request.RuleIds, helper.String(ruleId.(string)))
51+
}
52+
53+
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
54+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTeoV20220901Client().ModifyL7AccRulePriority(request)
55+
if e != nil {
56+
return tccommon.RetryError(e)
57+
} else {
58+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
59+
}
60+
return nil
61+
})
62+
if err != nil {
63+
return err
64+
}
65+
66+
d.SetId(zoneId)
67+
68+
return resourceTencentCloudTeoL7AccRulePriorityOperationRead(d, meta)
69+
}
70+
71+
func resourceTencentCloudTeoL7AccRulePriorityOperationRead(d *schema.ResourceData, meta interface{}) error {
72+
defer tccommon.LogElapsed("resource.tencentcloud_teo_l7_acc_rule_priority_operation.read")()
73+
defer tccommon.InconsistentCheck(d, meta)()
74+
75+
return nil
76+
}
77+
78+
func resourceTencentCloudTeoL7AccRulePriorityOperationDelete(d *schema.ResourceData, meta interface{}) error {
79+
defer tccommon.LogElapsed("resource.tencentcloud_teo_l7_acc_rule_priority_operation.delete")()
80+
defer tccommon.InconsistentCheck(d, meta)()
81+
82+
return nil
83+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
Provides a resource to set TEO l7 acc rules priority
2+
3+
Example Usage
4+
5+
```hcl
6+
resource "tencentcloud_teo_l7_acc_rule_v2" "rule1" {
7+
zone_id = "zone-39quuimqg8r6"
8+
description = ["1"]
9+
rule_name = "网站加速1"
10+
status = "enable"
11+
branches {
12+
condition = "$${http.request.host} in ['aaa.makn.cn']"
13+
actions {
14+
name = "Cache"
15+
cache_parameters {
16+
custom_time {
17+
cache_time = 2592000
18+
ignore_cache_control = "off"
19+
switch = "on"
20+
}
21+
}
22+
}
23+
24+
actions {
25+
name = "CacheKey"
26+
cache_key_parameters {
27+
full_url_cache = "on"
28+
ignore_case = "off"
29+
query_string {
30+
switch = "off"
31+
values = []
32+
}
33+
}
34+
}
35+
36+
sub_rules {
37+
description = ["1-1"]
38+
branches {
39+
condition = "lower($${http.request.file_extension}) in ['php', 'jsp', 'asp', 'aspx']"
40+
actions {
41+
name = "Cache"
42+
cache_parameters {
43+
no_cache {
44+
switch = "on"
45+
}
46+
}
47+
}
48+
}
49+
}
50+
51+
sub_rules {
52+
description = ["1-2"]
53+
branches {
54+
condition = "$${http.request.file_extension} in ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']"
55+
actions {
56+
name = "MaxAge"
57+
max_age_parameters {
58+
cache_time = 3600
59+
follow_origin = "off"
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
67+
resource "tencentcloud_teo_l7_acc_rule_v2" "rule2" {
68+
zone_id = "zone-39quuimqg8r6"
69+
description = ["2"]
70+
rule_name = "网站加速2"
71+
status = "enable"
72+
branches {
73+
condition = "$${http.request.host} in ['aaa.makn.cn']"
74+
actions {
75+
name = "Cache"
76+
cache_parameters {
77+
custom_time {
78+
cache_time = 2592000
79+
ignore_cache_control = "off"
80+
switch = "on"
81+
}
82+
}
83+
}
84+
85+
actions {
86+
name = "CacheKey"
87+
cache_key_parameters {
88+
full_url_cache = "on"
89+
ignore_case = "off"
90+
query_string {
91+
switch = "off"
92+
values = []
93+
}
94+
}
95+
}
96+
97+
sub_rules {
98+
description = ["1-1"]
99+
branches {
100+
condition = "lower($${http.request.file_extension}) in ['php', 'jsp', 'asp', 'aspx']"
101+
actions {
102+
name = "Cache"
103+
cache_parameters {
104+
no_cache {
105+
switch = "on"
106+
}
107+
}
108+
}
109+
}
110+
}
111+
112+
sub_rules {
113+
description = ["1-2"]
114+
branches {
115+
condition = "$${http.request.file_extension} in ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']"
116+
actions {
117+
name = "MaxAge"
118+
max_age_parameters {
119+
cache_time = 3600
120+
follow_origin = "off"
121+
}
122+
}
123+
}
124+
}
125+
}
126+
}
127+
128+
resource "tencentcloud_teo_l7_acc_rule_priority_operation" "teo_l7_acc_rule_priority_operation" {
129+
zone_id = "zone-39quuimqg8r6"
130+
rule_ids = [resource.tencentcloud_teo_l7_acc_rule_v2.rule2.rule_id, resource.tencentcloud_teo_l7_acc_rule_v2.rule1.rule_id]
131+
}
132+
```

0 commit comments

Comments
 (0)