Skip to content

Commit 050bd46

Browse files
author
ttomzhou
committed
Merge remote-tracking branch 'clb/master'
2 parents 2276579 + 99aae10 commit 050bd46

23 files changed

+1349
-106
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ DEPRECATED:
99

1010
* Resource: `tencentcloud_kubernetes_as_scaling_group` replaced by `tencentcloud_kubernetes_node_pool`.
1111

12+
ENHANCEMENTS:
13+
14+
* Resource `tencentcloud_ccn` add `charge_type` to support billing mode setting.
15+
* Resource `tencentcloud_ccn` add `bandwidth_limit_type` to support the speed limit type setting.
16+
* Resource `tencentcloud_ccn_bandwidth_limit` add `dst_region` to support destination area restriction setting.
17+
* Resource `tencentcloud_cdn_domain` add `range_origin_switch` to support range back to source configuration.
18+
* Resource `tencentcloud_cdn_domain` add `rule_cache` to support advanced path cache configuration.
19+
* Resource `tencentcloud_cdn_domain` add `request_header` to support request header configuration.
20+
* Data Source `tencentcloud_ccn_instances` add `charge_type` to support billing mode.
21+
* Data Source `tencentcloud_ccn_instances` add `bandwidth_limit_type` to support the speed limit type.
22+
* Data Source `tencentcloud_ccn_bandwidth_limit` add `dst_region` to support destination area restriction.
23+
* Data Source `tencentcloud_cdn_domains` add `range_origin_switch` to support range back to source configuration.
24+
* Data Source `tencentcloud_cdn_domains` add `rule_cache` to support advanced path cache configuration.
25+
* Data Source `tencentcloud_cdn_domains` add `request_header` to support request header configuration.
1226

1327
## 1.51.1 (December 22, 2020)
1428

examples/tencentcloud-cdn/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@ resource "tencentcloud_cdn_domain" "foo" {
22
domain = "xxxx.com"
33
service_type = "web"
44
area = "mainland"
5+
range_origin_switch = "off"
6+
7+
rule_cache{
8+
cache_time = 10000
9+
no_cache_switch="on"
10+
re_validate="on"
11+
}
12+
13+
request_header{
14+
switch = "on"
15+
16+
header_rules {
17+
header_mode = "add"
18+
header_name = "tf-header-name"
19+
header_value = "tf-header-value"
20+
rule_type = "all"
21+
rule_paths = ["*"]
22+
}
23+
}
524

625
origin {
726
origin_type = "ip"

tencentcloud/data_source_tc_ccn_bandwidth_limits.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ func dataSourceTencentCloudCcnBandwidthLimits() *schema.Resource {
6666
Computed: true,
6767
Description: "Limitation of bandwidth.",
6868
},
69+
"dst_region": {
70+
Type: schema.TypeString,
71+
Computed: true,
72+
Description: "Destination area restriction.",
73+
},
6974
},
7075
},
7176
},
@@ -85,7 +90,7 @@ func dataSourceTencentCloudCcnBandwidthLimitsRead(d *schema.ResourceData, meta i
8590
ccnId = d.Get("ccn_id").(string)
8691
)
8792

88-
var infos, err = service.DescribeCcnRegionBandwidthLimits(ctx, ccnId)
93+
var infos, err = service.GetCcnRegionBandwidthLimits(ctx, ccnId)
8994
if err != nil {
9095
return err
9196
}
@@ -94,8 +99,9 @@ func dataSourceTencentCloudCcnBandwidthLimitsRead(d *schema.ResourceData, meta i
9499

95100
for _, item := range infos {
96101
var infoMap = make(map[string]interface{})
97-
infoMap["region"] = item.region
98-
infoMap["bandwidth_limit"] = item.limit
102+
infoMap["region"] = item.Region
103+
infoMap["bandwidth_limit"] = item.BandwidthLimit
104+
infoMap["dst_region"] = item.DstRegion
99105
infoList = append(infoList, infoMap)
100106
}
101107
if err := d.Set("limits", infoList); err != nil {

tencentcloud/data_source_tc_ccn_bandwidth_limits_test.go

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,50 @@ import (
66
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
77
)
88

9-
func TestAccDataSourceTencentCloudCcnV3BandwidthLimitsBasic(t *testing.T) {
9+
func TestAccDataSourceTencentCloudCcnV3BandwidthLimitsOuter(t *testing.T) {
1010
keyName := "data.tencentcloud_ccn_bandwidth_limits.limit"
1111
resource.Test(t, resource.TestCase{
1212
PreCheck: func() { testAccPreCheck(t) },
1313
Providers: testAccProviders,
1414
Steps: []resource.TestStep{
1515
{
16-
Config: TestAccDataSourceTencentCloudCcnBandwidthLimits,
16+
Config: TestAccDataSourceTencentCloudCcnOuterBandwidthLimits,
1717

1818
Check: resource.ComposeTestCheckFunc(
1919
testAccCheckTencentCloudDataSourceID(keyName),
2020
resource.TestCheckResourceAttrSet(keyName, "ccn_id"),
21-
resource.TestCheckResourceAttrSet(keyName, "limits.#"),
21+
resource.TestCheckResourceAttr(keyName, "limits.#", "1"),
22+
resource.TestCheckResourceAttr(keyName, "limits.0.region", "ap-shanghai"),
23+
resource.TestCheckResourceAttr(keyName, "limits.0.bandwidth_limit", "500"),
2224
),
2325
},
2426
},
2527
})
2628
}
2729

28-
const TestAccDataSourceTencentCloudCcnBandwidthLimits = `
30+
func TestAccDataSourceTencentCloudCcnV3BandwidthLimitsInter(t *testing.T) {
31+
keyName := "data.tencentcloud_ccn_bandwidth_limits.limit"
32+
resource.Test(t, resource.TestCase{
33+
PreCheck: func() { testAccPreCheck(t) },
34+
Providers: testAccProviders,
35+
Steps: []resource.TestStep{
36+
{
37+
Config: TestAccDataSourceTencentCloudCcnInterBandwidthLimits,
2938

39+
Check: resource.ComposeTestCheckFunc(
40+
testAccCheckTencentCloudDataSourceID(keyName),
41+
resource.TestCheckResourceAttrSet(keyName, "ccn_id"),
42+
resource.TestCheckResourceAttr(keyName, "limits.#", "1"),
43+
resource.TestCheckResourceAttr(keyName, "limits.0.region", "ap-shanghai"),
44+
resource.TestCheckResourceAttr(keyName, "limits.0.dst_region", "ap-beijing"),
45+
resource.TestCheckResourceAttr(keyName, "limits.0.bandwidth_limit", "500"),
46+
),
47+
},
48+
},
49+
})
50+
}
51+
52+
const TestAccDataSourceTencentCloudCcnOuterBandwidthLimits = `
3053
variable "other_region1" {
3154
default = "ap-shanghai"
3255
}
@@ -37,13 +60,41 @@ resource tencentcloud_ccn main {
3760
qos = "AG"
3861
}
3962
63+
resource tencentcloud_ccn_bandwidth_limit limit1 {
64+
ccn_id = tencentcloud_ccn.main.id
65+
region = var.other_region1
66+
bandwidth_limit = 500
67+
}
68+
4069
data tencentcloud_ccn_bandwidth_limits limit {
41-
ccn_id = tencentcloud_ccn.main.id
70+
ccn_id = tencentcloud_ccn_bandwidth_limit.limit1.ccn_id
71+
}
72+
`
73+
74+
const TestAccDataSourceTencentCloudCcnInterBandwidthLimits = `
75+
variable "other_region1" {
76+
default = "ap-shanghai"
77+
}
78+
79+
variable "other_region2" {
80+
default = "ap-beijing"
81+
}
82+
83+
resource tencentcloud_ccn main {
84+
name = "ci-temp-test-ccn"
85+
description = "ci-temp-test-ccn-des"
86+
qos = "AG"
87+
bandwidth_limit_type = "INTER_REGION_LIMIT"
4288
}
4389
4490
resource tencentcloud_ccn_bandwidth_limit limit1 {
4591
ccn_id = tencentcloud_ccn.main.id
4692
region = var.other_region1
93+
dst_region = var.other_region2
4794
bandwidth_limit = 500
4895
}
96+
97+
data tencentcloud_ccn_bandwidth_limits limit {
98+
ccn_id = tencentcloud_ccn_bandwidth_limit.limit1.ccn_id
99+
}
49100
`

tencentcloud/data_source_tc_ccn_instances.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ func dataSourceTencentCloudCcnInstances() *schema.Resource {
8484
Computed: true,
8585
Description: "States of instance. The available value include 'ISOLATED'(arrears) and 'AVAILABLE'.",
8686
},
87+
"charge_type": {
88+
Type: schema.TypeString,
89+
Computed: true,
90+
Description: "Billing mode.",
91+
},
92+
"bandwidth_limit_type": {
93+
Type: schema.TypeString,
94+
Computed: true,
95+
Description: "The speed limit type.",
96+
},
8797
"attachment_list": {
8898
Type: schema.TypeList,
8999
Computed: true,
@@ -178,6 +188,8 @@ func dataSourceTencentCloudCcnInstancesRead(d *schema.ResourceData, meta interfa
178188
infoMap["qos"] = item.qos
179189
infoMap["state"] = strings.ToUpper(item.state)
180190
infoMap["create_time"] = item.createTime
191+
infoMap["charge_type"] = item.chargeType
192+
infoMap["bandwidth_limit_type"] = item.bandWithLimitType
181193
infoList = append(infoList, infoMap)
182194

183195
instances, err := service.DescribeCcnAttachedInstances(ctx, item.ccnId)

tencentcloud/data_source_tc_ccn_instances_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ func TestAccDataSourceTencentCloudCcnV3InstancesBasic(t *testing.T) {
2525
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.ccn_id"),
2626
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.qos"),
2727
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.state"),
28+
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.charge_type"),
29+
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.bandwidth_limit_type"),
2830
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.attachment_list.#"),
2931
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.create_time"),
3032

@@ -36,6 +38,8 @@ func TestAccDataSourceTencentCloudCcnV3InstancesBasic(t *testing.T) {
3638
resource.TestCheckResourceAttrSet(keyName, "instance_list.0.ccn_id"),
3739
resource.TestCheckResourceAttrSet(keyName, "instance_list.0.qos"),
3840
resource.TestCheckResourceAttrSet(keyName, "instance_list.0.state"),
41+
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.charge_type"),
42+
resource.TestCheckResourceAttrSet(keyId, "instance_list.0.bandwidth_limit_type"),
3943
resource.TestCheckResourceAttrSet(keyName, "instance_list.0.attachment_list.#"),
4044
resource.TestCheckResourceAttrSet(keyName, "instance_list.0.create_time"),
4145
),

0 commit comments

Comments
 (0)