Skip to content

fix(teo): [122612321] modify l7 acc rule #3247

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 7 commits into from
Mar 28, 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/3247.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_teo_l7_acc_rule: Fix the problem of modifying rules and supporting the order of rules.
```
219 changes: 56 additions & 163 deletions 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.

8 changes: 2 additions & 6 deletions tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Provides a resource to create a teo l7_acc_rule

~> **NOTE:** This feature only supports the sites in the plans of the Standard Edition and the Enterprise Edition.

Example Usage

```hcl
Expand All @@ -8,7 +10,6 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" {
rules {
description = ["1"]
rule_name = "网站加速"
status = "disable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
actions {
Expand Down Expand Up @@ -66,7 +67,6 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" {
rules {
description = ["2"]
rule_name = "音视频直播"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
sub_rules {
Expand Down Expand Up @@ -117,7 +117,6 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" {
rules {
description = ["3"]
rule_name = "大文件下载"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
actions {
Expand Down Expand Up @@ -168,7 +167,6 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" {
rules {
description = ["4"]
rule_name = "音视频点播"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
actions {
Expand Down Expand Up @@ -219,7 +217,6 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" {
rules {
description = ["5"]
rule_name = "API 加速"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
actions {
Expand All @@ -241,7 +238,6 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" {
rules {
description = ["6"]
rule_name = "WordPress 建站"
status = "enable"
branches {
condition = "$${http.request.host} in ['aaa.makn.cn']"
sub_rules {
Expand Down
18 changes: 18 additions & 0 deletions tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_extension.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package teo

import (
"encoding/json"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
teo "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
teov20220901 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/teo/v20220901"
Expand Down Expand Up @@ -2464,3 +2466,19 @@ func resourceTencentCloudTeoL7AccRuleSetBranchs(ruleBranches []*teo.RuleBranch)
}
return branchesList
}

func resourceTencentCloudTeoL7AccRuleContent(rules []*teo.RuleEngineItem) (string, error) {
type Content struct {
FormatVersion string `json:"FormatVersion,omitempty"`
Rules []*teo.RuleEngineItem `json:"Rules,omitempty"`
}
content := Content{
FormatVersion: "1.0",
Rules: rules,
}
contentBytes, err := json.Marshal(content)
if err != nil {
return "", err
}
return string(contentBytes), nil
}
Loading
Loading