@@ -3,11 +3,39 @@ Provides a resource to create a CCN instance.
33
44Example Usage
55
6+ Create a prepaid CCN
7+
8+ ```hcl
9+ resource "tencentcloud_ccn" "main" {
10+ name = "ci-temp-test-ccn"
11+ description = "ci-temp-test-ccn-des"
12+ qos = "AG"
13+ charge_type = "PREPAID"
14+ bandwidth_limit_type = "INTER_REGION_LIMIT"
15+ }
16+ ```
17+
18+ Create a post-paid regional export speed limit type CCN
19+
20+ ```hcl
21+ resource "tencentcloud_ccn" "main" {
22+ name = "ci-temp-test-ccn"
23+ description = "ci-temp-test-ccn-des"
24+ qos = "AG"
25+ charge_type = "POSTPAID"
26+ bandwidth_limit_type = "OUTER_REGION_LIMIT"
27+ }
28+ ```
29+
30+ Create a post-paid inter-regional rate limit type CNN
31+
632```hcl
733resource "tencentcloud_ccn" "main" {
8- name = "ci-temp-test-ccn"
9- description = "ci-temp-test-ccn-des"
10- qos = "AG"
34+ name = "ci-temp-test-ccn"
35+ description = "ci-temp-test-ccn-des"
36+ qos = "AG"
37+ charge_type = "POSTPAID"
38+ bandwidth_limit_type = "INTER_REGION_LIMIT"
1139}
1240```
1341
@@ -62,6 +90,28 @@ func resourceTencentCloudCcn() *schema.Resource {
6290 ValidateFunc : validateAllowedStringValue ([]string {CNN_QOS_PT , CNN_QOS_AU , CNN_QOS_AG }),
6391 Description : "Service quality of CCN. Valid values: `PT`, `AU`, `AG`. The default is `AU`." ,
6492 },
93+ "charge_type" : {
94+ Type : schema .TypeString ,
95+ Optional : true ,
96+ ForceNew : true ,
97+ Default : POSTPAID ,
98+ ValidateFunc : validateAllowedStringValue ([]string {POSTPAID , PREPAID }),
99+ Description : "Billing mode. Valid values: `PREPAID`, `POSTPAID`. " +
100+ "`PREPAID` means prepaid, which means annual and monthly subscription, " +
101+ "`POSTPAID` means post-payment, which means billing by volume. " +
102+ "The default is `POSTPAID`. The prepaid model only supports inter-regional speed limit, " +
103+ "and the post-paid model supports inter-regional speed limit and regional export speed limit." ,
104+ },
105+ "bandwidth_limit_type" : {
106+ Type : schema .TypeString ,
107+ Optional : true ,
108+ Default : OuterRegionLimit ,
109+ ValidateFunc : validateAllowedStringValue ([]string {OuterRegionLimit , InterRegionLimit }),
110+ Description : "The speed limit type. Valid values: `INTER_REGION_LIMIT`, `OUTER_REGION_LIMIT`. " +
111+ "`OUTER_REGION_LIMIT` represents the regional export speed limit, " +
112+ "`INTER_REGION_LIMIT` is the inter-regional speed limit. " +
113+ "The default is `OUTER_REGION_LIMIT`." ,
114+ },
65115 // Computed values
66116 "state" : {
67117 Type : schema .TypeString ,
@@ -96,14 +146,16 @@ func resourceTencentCloudCcnCreate(d *schema.ResourceData, meta interface{}) err
96146 service := VpcService {client : meta .(* TencentCloudClient ).apiV3Conn }
97147
98148 var (
99- name = d .Get ("name" ).(string )
100- description = ""
101- qos = d .Get ("qos" ).(string )
149+ name = d .Get ("name" ).(string )
150+ description = ""
151+ qos = d .Get ("qos" ).(string )
152+ chargeType = d .Get ("charge_type" ).(string )
153+ bandwidthLimitType = d .Get ("bandwidth_limit_type" ).(string )
102154 )
103155 if temp , ok := d .GetOk ("description" ); ok {
104156 description = temp .(string )
105157 }
106- info , err := service .CreateCcn (ctx , name , description , qos )
158+ info , err := service .CreateCcn (ctx , name , description , qos , chargeType , bandwidthLimitType )
107159 if err != nil {
108160 return err
109161 }
@@ -146,6 +198,8 @@ func resourceTencentCloudCcnRead(d *schema.ResourceData, meta interface{}) error
146198 _ = d .Set ("state" , strings .ToUpper (info .state ))
147199 _ = d .Set ("instance_count" , info .instanceCount )
148200 _ = d .Set ("create_time" , info .createTime )
201+ _ = d .Set ("charge_type" , info .chargeType )
202+ _ = d .Set ("bandwidth_limit_type" , info .bandWithLimitType )
149203
150204 return nil
151205 })
@@ -203,6 +257,19 @@ func resourceTencentCloudCcnUpdate(d *schema.ResourceData, meta interface{}) err
203257 d .SetPartial (val )
204258 }
205259 }
260+ // modify band width limit type
261+ if d .HasChange ("bandwidth_limit_type" ) {
262+ _ , news := d .GetChange ("bandwidth_limit_type" )
263+ if err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
264+ if err := service .ModifyCcnRegionBandwidthLimitsType (ctx , d .Id (), news .(string )); err != nil {
265+ return retryError (err )
266+ }
267+ return nil
268+ }); err != nil {
269+ return err
270+ }
271+ d .SetPartial ("bandwidth_limit_type" )
272+ }
206273
207274 if d .HasChange ("tags" ) {
208275
0 commit comments