diff --git a/.changelog/3325.txt b/.changelog/3325.txt new file mode 100644 index 0000000000..7f839d0ed0 --- /dev/null +++ b/.changelog/3325.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_teo_l7_acc_rule: update fileds +``` \ No newline at end of file diff --git a/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.md b/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.md index b7f266c24c..eae4c4af4d 100644 --- a/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.md +++ b/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule.md @@ -1,11 +1,11 @@ -Provides a resource to create a teo l7_acc_rule +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 -resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { +resource "tencentcloud_teo_l7_acc_rule" "example" { zone_id = "zone-36bjhygh1bxe" rules { description = ["1"] @@ -22,6 +22,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "CacheKey" cache_key_parameters { @@ -35,6 +36,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + sub_rules { description = ["1-1"] branches { @@ -49,6 +51,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + sub_rules { description = ["1-2"] branches { @@ -64,6 +67,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["2"] rule_name = "音视频直播" @@ -84,6 +88,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.file_extension} in ['ts', 'mp4', 'm4a', 'm4s']" actions { @@ -97,6 +102,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "*" actions { @@ -114,6 +120,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["3"] rule_name = "大文件下载" @@ -129,6 +136,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "CacheKey" cache_key_parameters { @@ -142,12 +150,14 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "RangeOriginPull" range_origin_pull_parameters { switch = "on" } } + sub_rules { description = ["3-1"] branches { @@ -164,6 +174,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["4"] rule_name = "音视频点播" @@ -179,6 +190,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "CacheKey" cache_key_parameters { @@ -192,12 +204,14 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "RangeOriginPull" range_origin_pull_parameters { switch = "on" } } + sub_rules { description = ["4-1"] branches { @@ -214,6 +228,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["5"] rule_name = "API 加速" @@ -227,6 +242,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "SmartRouting" smart_routing_parameters { @@ -235,6 +251,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["6"] rule_name = "WordPress 建站" @@ -255,6 +272,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.uri.path} in ['/']" actions { @@ -266,6 +284,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.file_extension} in ['aspx', 'jsp', 'php', 'asp', 'do', 'dwr', 'cgi', 'fcgi', 'action', 'ashx', 'axd']" actions { @@ -277,6 +296,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.uri.path} in ['/wp-admin/']" actions { @@ -288,6 +308,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "*" actions { @@ -306,11 +327,12 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } - ``` + Import -teo l7_acc_rule can be imported using the zone_id, e.g. +TEO l7 acc rule can be imported using the zone_id, e.g. + +```` +terraform import tencentcloud_teo_l7_acc_rule.example zone-36bjhygh1bxe ```` -terraform import tencentcloud_teo_l7_acc_rule.teo_l7_acc_rule zone-297z8rf93cfw -```` \ No newline at end of file diff --git a/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_extension.go b/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_extension.go index 6dcf701926..a889b49269 100644 --- a/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_extension.go +++ b/tencentcloud/services/teo/resource_tc_teo_l7_acc_rule_extension.go @@ -6,6 +6,7 @@ import ( "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" + tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" ) @@ -837,14 +838,16 @@ func TencentTeoL7RuleBranchBasicInfo(depth int) map[string]*schema.Schema { Description: "Origin-Pull protocol configuration. this parameter is required when origintype is ipdomain, origingroup, or loadbalance. valid values are: Http: use http protocol; Https: use https protocol; Follow: follow the protocol.", }, "http_origin_port": { - Type: schema.TypeInt, - Optional: true, - Description: "Ports for http origin-pull requests. value range: 1-65535. this parameter takes effect only when the origin-pull protocol originprotocol is http or follow.", + Type: schema.TypeInt, + Optional: true, + ValidateFunc: tccommon.ValidateIntegerInRange(1, 65535), + Description: "Ports for http origin-pull requests. value range: 1-65535. this parameter takes effect only when the origin-pull protocol originprotocol is http or follow.", }, "https_origin_port": { - Type: schema.TypeInt, - Optional: true, - Description: "Ports for https origin-pull requests. value range: 1-65535. this parameter takes effect only when the origin-pull protocol originprotocol is https or follow.", + Type: schema.TypeInt, + Optional: true, + ValidateFunc: tccommon.ValidateIntegerInRange(1, 65535), + Description: "Ports for https origin-pull requests. value range: 1-65535. this parameter takes effect only when the origin-pull protocol originprotocol is https or follow.", }, "private_access": { Type: schema.TypeString, @@ -1539,10 +1542,10 @@ func resourceTencentCloudTeoL7AccRuleGetBranchs(rulesMap map[string]interface{}) if v, ok := modifyOriginParametersMap["origin_protocol"].(string); ok && v != "" { modifyOriginParameters.OriginProtocol = helper.String(v) } - if v, ok := modifyOriginParametersMap["http_origin_port"].(int); ok { + if v, ok := modifyOriginParametersMap["http_origin_port"].(int); ok && v != 0 { modifyOriginParameters.HTTPOriginPort = helper.IntInt64(v) } - if v, ok := modifyOriginParametersMap["https_origin_port"].(int); ok { + if v, ok := modifyOriginParametersMap["https_origin_port"].(int); ok && v != 0 { modifyOriginParameters.HTTPSOriginPort = helper.IntInt64(v) } if v, ok := modifyOriginParametersMap["private_access"].(string); ok && v != "" { diff --git a/website/docs/r/teo_l7_acc_rule.html.markdown b/website/docs/r/teo_l7_acc_rule.html.markdown index f31866fa06..c7e396b2d6 100644 --- a/website/docs/r/teo_l7_acc_rule.html.markdown +++ b/website/docs/r/teo_l7_acc_rule.html.markdown @@ -4,19 +4,19 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_teo_l7_acc_rule" sidebar_current: "docs-tencentcloud-resource-teo_l7_acc_rule" description: |- - Provides a resource to create a teo l7_acc_rule + Provides a resource to create a TEO l7 acc rule --- # tencentcloud_teo_l7_acc_rule -Provides a resource to create a teo l7_acc_rule +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 -resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { +resource "tencentcloud_teo_l7_acc_rule" "example" { zone_id = "zone-36bjhygh1bxe" rules { description = ["1"] @@ -33,6 +33,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "CacheKey" cache_key_parameters { @@ -46,6 +47,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + sub_rules { description = ["1-1"] branches { @@ -60,6 +62,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + sub_rules { description = ["1-2"] branches { @@ -75,6 +78,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["2"] rule_name = "音视频直播" @@ -95,6 +99,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.file_extension} in ['ts', 'mp4', 'm4a', 'm4s']" actions { @@ -108,6 +113,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "*" actions { @@ -125,6 +131,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["3"] rule_name = "大文件下载" @@ -140,6 +147,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "CacheKey" cache_key_parameters { @@ -153,12 +161,14 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "RangeOriginPull" range_origin_pull_parameters { switch = "on" } } + sub_rules { description = ["3-1"] branches { @@ -175,6 +185,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["4"] rule_name = "音视频点播" @@ -190,6 +201,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "CacheKey" cache_key_parameters { @@ -203,12 +215,14 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "RangeOriginPull" range_origin_pull_parameters { switch = "on" } } + sub_rules { description = ["4-1"] branches { @@ -225,6 +239,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["5"] rule_name = "API 加速" @@ -238,6 +253,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + actions { name = "SmartRouting" smart_routing_parameters { @@ -246,6 +262,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + rules { description = ["6"] rule_name = "WordPress 建站" @@ -266,6 +283,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.uri.path} in ['/']" actions { @@ -277,6 +295,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.file_extension} in ['aspx', 'jsp', 'php', 'asp', 'do', 'dwr', 'cgi', 'fcgi', 'action', 'ashx', 'axd']" actions { @@ -288,6 +307,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "$${http.request.uri.path} in ['/wp-admin/']" actions { @@ -299,6 +319,7 @@ resource "tencentcloud_teo_l7_acc_rule" "teo_l7_acc_rule" { } } } + branches { condition = "*" actions { @@ -712,8 +733,9 @@ In addition to all arguments above, the following attributes are exported: ## Import -teo l7_acc_rule can be imported using the zone_id, e.g. +TEO l7 acc rule can be imported using the zone_id, e.g. + ```` -terraform import tencentcloud_teo_l7_acc_rule.teo_l7_acc_rule zone-297z8rf93cfw +terraform import tencentcloud_teo_l7_acc_rule.example zone-36bjhygh1bxe ````