Skip to content

fix(teo): [123732420] support teo l7 rule v2 #3376

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

Merged
merged 2 commits into from
May 23, 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
7 changes: 7 additions & 0 deletions .changelog/3376.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:new-resource
tencentcloud_teo_l7_acc_rule_v2
```

```release-note:new-resource
tencentcloud_teo_l7_acc_rule_priority_operation
```
2 changes: 2 additions & 0 deletions tencentcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,8 @@ func Provider() *schema.Provider {
"tencentcloud_teo_l4_proxy": teo.ResourceTencentCloudTeoL4Proxy(),
"tencentcloud_teo_l4_proxy_rule": teo.ResourceTencentCloudTeoL4ProxyRule(),
"tencentcloud_teo_l7_acc_rule": teo.ResourceTencentCloudTeoL7AccRule(),
"tencentcloud_teo_l7_acc_rule_v2": teo.ResourceTencentCloudTeoL7AccRuleV2(),
"tencentcloud_teo_l7_acc_rule_priority_operation": teo.ResourceTencentCloudTeoL7AccRulePriorityOperation(),
"tencentcloud_teo_l7_acc_setting": teo.ResourceTencentCloudTeoL7AccSetting(),
"tencentcloud_teo_rule_engine": teo.ResourceTencentCloudTeoRuleEngine(),
"tencentcloud_teo_ownership_verify": teo.ResourceTencentCloudTeoOwnershipVerify(),
Expand Down
2 changes: 2 additions & 0 deletions tencentcloud/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,8 @@ tencentcloud_teo_function_rule
tencentcloud_teo_function_rule_priority
tencentcloud_teo_function_runtime_environment
tencentcloud_teo_l7_acc_rule
tencentcloud_teo_l7_acc_rule_v2
tencentcloud_teo_l7_acc_rule_priority_operation
tencentcloud_teo_l7_acc_setting
tencentcloud_teo_security_ip_group
tencentcloud_teo_security_policy_config
Expand Down
2 changes: 1 addition & 1 deletion tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package teo

import (
"log"

teov20220901 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func ResourceTencentCloudTeoL7AccRulePriorityOperation() *schema.Resource {
return &schema.Resource{
Create: resourceTencentCloudTeoL7AccRulePriorityOperationCreate,
Read: resourceTencentCloudTeoL7AccRulePriorityOperationRead,
Delete: resourceTencentCloudTeoL7AccRulePriorityOperationDelete,
Schema: map[string]*schema.Schema{
"zone_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Zone id.",
},
"rule_ids": {
Type: schema.TypeList,
Required: true,
ForceNew: true,
Description: "Complete list of rule IDs under site ID.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
}

func resourceTencentCloudTeoL7AccRulePriorityOperationCreate(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_teo_l7_acc_rule_priority_operation.create")()
defer tccommon.InconsistentCheck(d, meta)()

logId := tccommon.GetLogId(tccommon.ContextNil)

request := teov20220901.NewModifyL7AccRulePriorityRequest()
zoneId := d.Get("zone_id").(string)
request.ZoneId = helper.String(zoneId)
ruleIds := d.Get("rule_ids").([]interface{})
for _, ruleId := range ruleIds {
request.RuleIds = append(request.RuleIds, helper.String(ruleId.(string)))
}

err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTeoV20220901Client().ModifyL7AccRulePriority(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}
return nil
})
if err != nil {
return err
}

d.SetId(zoneId)

return resourceTencentCloudTeoL7AccRulePriorityOperationRead(d, meta)
}

func resourceTencentCloudTeoL7AccRulePriorityOperationRead(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_teo_l7_acc_rule_priority_operation.read")()
defer tccommon.InconsistentCheck(d, meta)()

return nil
}

func resourceTencentCloudTeoL7AccRulePriorityOperationDelete(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_teo_l7_acc_rule_priority_operation.delete")()
defer tccommon.InconsistentCheck(d, meta)()

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
Provides a resource to set TEO l7 acc rules priority

Example Usage

```hcl
resource "tencentcloud_teo_l7_acc_rule_v2" "rule1" {
zone_id = "zone-39quuimqg8r6"
description = ["1"]
rule_name = "网站加速1"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
actions {
name = "Cache"
cache_parameters {
custom_time {
cache_time = 2592000
ignore_cache_control = "off"
switch = "on"
}
}
}

actions {
name = "CacheKey"
cache_key_parameters {
full_url_cache = "on"
ignore_case = "off"
query_string {
switch = "off"
values = []
}
}
}

sub_rules {
description = ["1-1"]
branches {
condition = "lower($${http.request.file_extension}) in ['php', 'jsp', 'asp', 'aspx']"
actions {
name = "Cache"
cache_parameters {
no_cache {
switch = "on"
}
}
}
}
}

sub_rules {
description = ["1-2"]
branches {
condition = "$${http.request.file_extension} in ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']"
actions {
name = "MaxAge"
max_age_parameters {
cache_time = 3600
follow_origin = "off"
}
}
}
}
}
}

resource "tencentcloud_teo_l7_acc_rule_v2" "rule2" {
zone_id = "zone-39quuimqg8r6"
description = ["2"]
rule_name = "网站加速2"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
actions {
name = "Cache"
cache_parameters {
custom_time {
cache_time = 2592000
ignore_cache_control = "off"
switch = "on"
}
}
}

actions {
name = "CacheKey"
cache_key_parameters {
full_url_cache = "on"
ignore_case = "off"
query_string {
switch = "off"
values = []
}
}
}

sub_rules {
description = ["1-1"]
branches {
condition = "lower($${http.request.file_extension}) in ['php', 'jsp', 'asp', 'aspx']"
actions {
name = "Cache"
cache_parameters {
no_cache {
switch = "on"
}
}
}
}
}

sub_rules {
description = ["1-2"]
branches {
condition = "$${http.request.file_extension} in ['jpg', 'png', 'gif', 'bmp', 'svg', 'webp']"
actions {
name = "MaxAge"
max_age_parameters {
cache_time = 3600
follow_origin = "off"
}
}
}
}
}
}

resource "tencentcloud_teo_l7_acc_rule_priority_operation" "teo_l7_acc_rule_priority_operation" {
zone_id = "zone-39quuimqg8r6"
rule_ids = [resource.tencentcloud_teo_l7_acc_rule_v2.rule2.rule_id, resource.tencentcloud_teo_l7_acc_rule_v2.rule1.rule_id]
}
```
Loading
Loading