Skip to content

Commit 6ba8afd

Browse files
committed
add
1 parent 61ad762 commit 6ba8afd

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tencentcloud/services/cos/resource_tc_cos_bucket.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,50 @@ func ResourceTencentCloudCosBucket() *schema.Resource {
484484
ValidateFunc: tccommon.ValidateAllowedStringValue([]string{"http", "https"}),
485485
Description: "Redirects all request configurations. Valid values: http, https. Default is `http`.",
486486
},
487+
"routing_rules": {
488+
Type: schema.TypeList,
489+
Optional: true,
490+
MaxItems: 1,
491+
Description: "Routing rule configuration. A RoutingRules container can contain up to 100 RoutingRule elements.",
492+
Elem: &schema.Resource{
493+
Schema: map[string]*schema.Schema{
494+
"rules": {
495+
Type: schema.TypeList,
496+
Required: true,
497+
Description: "Routing rule list.",
498+
Elem: &schema.Resource{
499+
Schema: map[string]*schema.Schema{
500+
"condition_error_code": {
501+
Type: schema.TypeString,
502+
Optional: true,
503+
Description: "Specifies the error code as the match condition for the routing rule. Valid values: only 4xx return codes, such as 403 or 404.",
504+
},
505+
"condition_prefix": {
506+
Type: schema.TypeString,
507+
Optional: true,
508+
Description: "Specifies the object key prefix as the match condition for the routing rule.",
509+
},
510+
"redirect_protocol": {
511+
Type: schema.TypeString,
512+
Optional: true,
513+
Description: "Specifies the target protocol for the routing rule. Only HTTPS is supported.",
514+
},
515+
"redirect_replace_key": {
516+
Type: schema.TypeString,
517+
Optional: true,
518+
Description: "Specifies the target object key to replace the original object key in the request.",
519+
},
520+
"redirect_replace_key_prefix": {
521+
Type: schema.TypeString,
522+
Optional: true,
523+
Description: "Specifies the object key prefix to replace the original prefix in the request. You can set this parameter only if the condition is KeyPrefixEquals.",
524+
},
525+
},
526+
},
527+
},
528+
},
529+
},
530+
},
487531
"endpoint": {
488532
Type: schema.TypeString,
489533
Computed: true,
@@ -1442,6 +1486,45 @@ func resourceTencentCloudCosBucketWebsiteUpdate(ctx context.Context, meta interf
14421486
}
14431487
}
14441488

1489+
if v, ok := w["routing_rules"]; ok {
1490+
websiteRoutingRules := cos.WebsiteRoutingRules{}
1491+
for _, item := range v.([]interface{}) {
1492+
rules := item.(map[string]interface{})
1493+
if v, ok := rules["rules"]; ok {
1494+
wbRules := []cos.WebsiteRoutingRule{}
1495+
for _, rule := range v.([]interface{}) {
1496+
dMap := rule.(map[string]interface{})
1497+
wbRule := cos.WebsiteRoutingRule{}
1498+
if v, ok := dMap["condition_error_code"].(string); ok && v != "" {
1499+
wbRule.ConditionErrorCode = v
1500+
}
1501+
1502+
if v, ok := dMap["condition_prefix"].(string); ok && v != "" {
1503+
wbRule.ConditionPrefix = v
1504+
}
1505+
1506+
if v, ok := dMap["redirect_protocol"].(string); ok && v != "" {
1507+
wbRule.RedirectProtocol = v
1508+
}
1509+
1510+
if v, ok := dMap["redirect_replace_key"].(string); ok && v != "" {
1511+
wbRule.RedirectReplaceKey = v
1512+
}
1513+
1514+
if v, ok := dMap["redirect_replace_key_prefix"].(string); ok && v != "" {
1515+
wbRule.RedirectReplaceKeyPrefix = v
1516+
}
1517+
1518+
wbRules = append(wbRules, wbRule)
1519+
}
1520+
1521+
websiteRoutingRules.Rules = wbRules
1522+
}
1523+
}
1524+
1525+
websiteConfiguration.RoutingRules = &websiteRoutingRules
1526+
}
1527+
14451528
request := websiteConfiguration
14461529
response, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTencentCosClientNew(bucket, cdcId).Bucket.PutWebsite(ctx, &request)
14471530
if err != nil {

0 commit comments

Comments
 (0)