Skip to content

Commit b83b88d

Browse files
authored
fix(ccn): [124357697] tencentcloud_ccn update params (#3385)
* add * add
1 parent 827e988 commit b83b88d

File tree

4 files changed

+58
-39
lines changed

4 files changed

+58
-39
lines changed

.changelog/3385.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_ccn: update params
3+
```

tencentcloud/services/ccn/resource_tc_ccn.go

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ func ResourceTencentCloudCcn() *schema.Resource {
7373
"route_ecmp_flag": {
7474
Type: schema.TypeBool,
7575
Optional: true,
76-
Default: false,
77-
Description: "Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled.",
76+
Computed: true,
77+
Description: "Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled. Default is false.",
7878
},
7979
"route_overlap_flag": {
8080
Type: schema.TypeBool,
8181
Optional: true,
82-
Default: false,
83-
Description: "Whether to enable the routing overlap function. `true`: enabled, `false`: disabled.",
82+
Computed: true,
83+
Description: "Whether to enable the routing overlap function. `true`: enabled, `false`: disabled. Default is true, cannot set to false.",
8484
},
8585
"tags": {
8686
Type: schema.TypeMap,
@@ -158,36 +158,48 @@ func resourceTencentCloudCcnCreate(d *schema.ResourceData, meta interface{}) err
158158
}
159159

160160
// set ECMP/Overlap
161-
request := vpc.NewModifyCcnAttributeRequest()
162-
request.CcnId = &info.ccnId
161+
var (
162+
hasRouteECMP bool
163+
hasRouteOverlap bool
164+
routeECMPFlag bool
165+
routeOverlapFlag bool
166+
)
167+
163168
if temp, ok := d.GetOkExists("route_ecmp_flag"); ok {
164-
request.RouteECMPFlag = helper.Bool(temp.(bool))
169+
routeECMPFlag = temp.(bool)
170+
hasRouteECMP = true
165171
}
166172

167173
if temp, ok := d.GetOkExists("route_overlap_flag"); ok {
168-
request.RouteOverlapFlag = helper.Bool(temp.(bool))
174+
routeOverlapFlag = temp.(bool)
175+
hasRouteOverlap = true
169176
}
170177

171-
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
172-
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyCcnAttribute(request)
173-
if e != nil {
174-
return tccommon.RetryError(e)
175-
} else {
176-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
177-
}
178+
if hasRouteECMP || hasRouteOverlap {
179+
request := vpc.NewModifyCcnAttributeRequest()
180+
request.CcnId = &info.ccnId
181+
request.RouteECMPFlag = helper.Bool(routeECMPFlag)
182+
request.RouteOverlapFlag = helper.Bool(routeOverlapFlag)
183+
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
184+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyCcnAttribute(request)
185+
if e != nil {
186+
return tccommon.RetryError(e)
187+
} else {
188+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
189+
}
178190

179-
if result == nil {
180-
e = fmt.Errorf("update ModifyCcnAttribute failed")
181-
return resource.NonRetryableError(e)
182-
}
191+
if result == nil {
192+
e = fmt.Errorf("update ModifyCcnAttribute failed")
193+
return resource.NonRetryableError(e)
194+
}
183195

184-
_ = result
185-
return nil
186-
})
196+
return nil
197+
})
187198

188-
if err != nil {
189-
log.Printf("[CRITAL]%s update ModifyCcnAttribute failed, reason:%s\n", logId, err.Error())
190-
return err
199+
if err != nil {
200+
log.Printf("[CRITAL]%s update ModifyCcnAttribute failed, reason:%s\n", logId, err.Error())
201+
return err
202+
}
191203
}
192204

193205
return resourceTencentCloudCcnRead(d, meta)

tencentcloud/services/ccn/resource_tc_ccn.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
Provides a resource to create a CCN instance.
22

3+
~> **NOTE:** `route_overlap_flag` currently does not support setting to `false`.
4+
35
Example Usage
46

5-
Create a prepaid CCN
7+
Create a PREPAID CCN
68

79
```hcl
810
resource "tencentcloud_ccn" "example" {
@@ -14,12 +16,12 @@ resource "tencentcloud_ccn" "example" {
1416
route_ecmp_flag = true
1517
route_overlap_flag = true
1618
tags = {
17-
createBy = "terraform"
19+
createBy = "Terraform"
1820
}
1921
}
2022
```
2123

22-
Create a post-paid regional export speed limit type CCN
24+
Create a POSTPAID regional export speed limit type CCN
2325

2426
```hcl
2527
resource "tencentcloud_ccn" "example" {
@@ -29,14 +31,14 @@ resource "tencentcloud_ccn" "example" {
2931
charge_type = "POSTPAID"
3032
bandwidth_limit_type = "OUTER_REGION_LIMIT"
3133
route_ecmp_flag = false
32-
route_overlap_flag = false
34+
route_overlap_flag = true
3335
tags = {
34-
createBy = "terraform"
36+
createBy = "Terraform"
3537
}
3638
}
3739
```
3840

39-
Create a post-paid inter-regional rate limit type CNN
41+
Create a POSTPAID inter-regional rate limit type CNN
4042

4143
```hcl
4244
resource "tencentcloud_ccn" "example" {

website/docs/r/ccn.html.markdown

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ description: |-
1111

1212
Provides a resource to create a CCN instance.
1313

14+
~> **NOTE:** `route_overlap_flag` currently does not support setting to `false`.
15+
1416
## Example Usage
1517

16-
### Create a prepaid CCN
18+
### Create a PREPAID CCN
1719

1820
```hcl
1921
resource "tencentcloud_ccn" "example" {
@@ -25,12 +27,12 @@ resource "tencentcloud_ccn" "example" {
2527
route_ecmp_flag = true
2628
route_overlap_flag = true
2729
tags = {
28-
createBy = "terraform"
30+
createBy = "Terraform"
2931
}
3032
}
3133
```
3234

33-
### Create a post-paid regional export speed limit type CCN
35+
### Create a POSTPAID regional export speed limit type CCN
3436

3537
```hcl
3638
resource "tencentcloud_ccn" "example" {
@@ -40,14 +42,14 @@ resource "tencentcloud_ccn" "example" {
4042
charge_type = "POSTPAID"
4143
bandwidth_limit_type = "OUTER_REGION_LIMIT"
4244
route_ecmp_flag = false
43-
route_overlap_flag = false
45+
route_overlap_flag = true
4446
tags = {
45-
createBy = "terraform"
47+
createBy = "Terraform"
4648
}
4749
}
4850
```
4951

50-
### Create a post-paid inter-regional rate limit type CNN
52+
### Create a POSTPAID inter-regional rate limit type CNN
5153

5254
```hcl
5355
resource "tencentcloud_ccn" "example" {
@@ -68,8 +70,8 @@ The following arguments are supported:
6870
* `charge_type` - (Optional, String, ForceNew) Billing mode. Valid values: `PREPAID`, `POSTPAID`. `PREPAID` means prepaid, which means annual and monthly subscription, `POSTPAID` means post-payment, which means billing by volume. The default is `POSTPAID`. The prepaid model only supports inter-regional speed limit, and the post-paid model supports inter-regional speed limit and regional export speed limit.
6971
* `description` - (Optional, String) Description of CCN, and maximum length does not exceed 100 bytes.
7072
* `qos` - (Optional, String, ForceNew) CCN service quality, 'PT': Platinum, 'AU': Gold, 'AG': Silver. The default is 'AU'.
71-
* `route_ecmp_flag` - (Optional, Bool) Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled.
72-
* `route_overlap_flag` - (Optional, Bool) Whether to enable the routing overlap function. `true`: enabled, `false`: disabled.
73+
* `route_ecmp_flag` - (Optional, Bool) Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled. Default is false.
74+
* `route_overlap_flag` - (Optional, Bool) Whether to enable the routing overlap function. `true`: enabled, `false`: disabled. Default is true, cannot set to false.
7375
* `tags` - (Optional, Map) Instance tag.
7476

7577
## Attributes Reference

0 commit comments

Comments
 (0)