Skip to content

Commit b9a966f

Browse files
author
mikatong
committed
support tencentcloud_teo_l7_acc_rule_v2 and tencentcloud_teo_l7_acc_rule_priority_operation
1 parent e3318ff commit b9a966f

13 files changed

+1528
-2
lines changed

tencentcloud/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,8 @@ func Provider() *schema.Provider {
18521852
"tencentcloud_teo_l4_proxy": teo.ResourceTencentCloudTeoL4Proxy(),
18531853
"tencentcloud_teo_l4_proxy_rule": teo.ResourceTencentCloudTeoL4ProxyRule(),
18541854
"tencentcloud_teo_l7_acc_rule": teo.ResourceTencentCloudTeoL7AccRule(),
1855+
"tencentcloud_teo_l7_acc_rule_v2": teo.ResourceTencentCloudTeoL7AccRuleV2(),
1856+
"tencentcloud_teo_l7_acc_rule_priority_operation": teo.ResourceTencentCloudTeoL7AccRulePriorityOperation(),
18551857
"tencentcloud_teo_l7_acc_setting": teo.ResourceTencentCloudTeoL7AccSetting(),
18561858
"tencentcloud_teo_rule_engine": teo.ResourceTencentCloudTeoRuleEngine(),
18571859
"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+
```
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package teo_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
8+
)
9+
10+
func TestAccTencentCloudTeoL7AccRulePriorityOperationResource_basic(t *testing.T) {
11+
t.Parallel()
12+
resource.Test(t, resource.TestCase{
13+
PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PRIVATE) },
14+
Providers: tcacctest.AccProviders,
15+
Steps: []resource.TestStep{
16+
{
17+
Config: testAccTeoL7AccRulePriorityOperation,
18+
Check: resource.ComposeTestCheckFunc(
19+
resource.TestCheckResourceAttrSet("tencentcloud_teo_l7_acc_rule_priority_operation.teo_l7_acc_rule_priority_operation", "id"),
20+
),
21+
},
22+
},
23+
})
24+
}
25+
26+
const testAccTeoL7AccRulePriorityOperation = `
27+
resource "tencentcloud_teo_l7_acc_rule_v2" "rule1" {
28+
zone_id = "zone-39quuimqg8r6"
29+
description = ["1"]
30+
rule_name = "网站加速1"
31+
status = "enable"
32+
branches {
33+
condition = "$${http.request.host} in ['aaa.makn.cn']"
34+
actions {
35+
name = "Cache"
36+
cache_parameters {
37+
custom_time {
38+
cache_time = 2592000
39+
ignore_cache_control = "off"
40+
switch = "on"
41+
}
42+
}
43+
}
44+
45+
actions {
46+
name = "CacheKey"
47+
cache_key_parameters {
48+
full_url_cache = "on"
49+
ignore_case = "off"
50+
query_string {
51+
switch = "off"
52+
values = []
53+
}
54+
}
55+
}
56+
57+
sub_rules {
58+
description = ["1-1"]
59+
branches {
60+
condition = "lower($${http.request.file_extension}) in ['php', 'jsp', 'asp', 'aspx']"
61+
actions {
62+
name = "Cache"
63+
cache_parameters {
64+
no_cache {
65+
switch = "on"
66+
}
67+
}
68+
}
69+
}
70+
}
71+
72+
sub_rules {
73+
description = ["1-2"]
74+
branches {
75+
condition = "$${http.request.file_extension} in ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']"
76+
actions {
77+
name = "MaxAge"
78+
max_age_parameters {
79+
cache_time = 3600
80+
follow_origin = "off"
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
87+
88+
resource "tencentcloud_teo_l7_acc_rule_v2" "rule2" {
89+
zone_id = "zone-39quuimqg8r6"
90+
description = ["2"]
91+
rule_name = "网站加速2"
92+
status = "enable"
93+
branches {
94+
condition = "$${http.request.host} in ['aaa.makn.cn']"
95+
actions {
96+
name = "Cache"
97+
cache_parameters {
98+
custom_time {
99+
cache_time = 2592000
100+
ignore_cache_control = "off"
101+
switch = "on"
102+
}
103+
}
104+
}
105+
106+
actions {
107+
name = "CacheKey"
108+
cache_key_parameters {
109+
full_url_cache = "on"
110+
ignore_case = "off"
111+
query_string {
112+
switch = "off"
113+
values = []
114+
}
115+
}
116+
}
117+
118+
sub_rules {
119+
description = ["1-1"]
120+
branches {
121+
condition = "lower($${http.request.file_extension}) in ['php', 'jsp', 'asp', 'aspx']"
122+
actions {
123+
name = "Cache"
124+
cache_parameters {
125+
no_cache {
126+
switch = "on"
127+
}
128+
}
129+
}
130+
}
131+
}
132+
133+
sub_rules {
134+
description = ["1-2"]
135+
branches {
136+
condition = "$${http.request.file_extension} in ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']"
137+
actions {
138+
name = "MaxAge"
139+
max_age_parameters {
140+
cache_time = 3600
141+
follow_origin = "off"
142+
}
143+
}
144+
}
145+
}
146+
}
147+
}
148+
149+
resource "tencentcloud_teo_l7_acc_rule_priority_operation" "teo_l7_acc_rule_priority_operation" {
150+
zone_id = "zone-39quuimqg8r6"
151+
rule_ids = [resource.tencentcloud_teo_l7_acc_rule_v2.rule2.rule_id, resource.tencentcloud_teo_l7_acc_rule_v2.rule1.rule_id]
152+
}
153+
`

0 commit comments

Comments
 (0)