Skip to content

fix(ccn): [124357697] tencentcloud_ccn update params #3385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3385.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_ccn: update params
```
62 changes: 37 additions & 25 deletions tencentcloud/services/ccn/resource_tc_ccn.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ func ResourceTencentCloudCcn() *schema.Resource {
"route_ecmp_flag": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled.",
Computed: true,
Description: "Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled. Default is false.",
},
"route_overlap_flag": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to enable the routing overlap function. `true`: enabled, `false`: disabled.",
Computed: true,
Description: "Whether to enable the routing overlap function. `true`: enabled, `false`: disabled. Default is true, cannot set to false.",
},
"tags": {
Type: schema.TypeMap,
Expand Down Expand Up @@ -158,36 +158,48 @@ func resourceTencentCloudCcnCreate(d *schema.ResourceData, meta interface{}) err
}

// set ECMP/Overlap
request := vpc.NewModifyCcnAttributeRequest()
request.CcnId = &info.ccnId
var (
hasRouteECMP bool
hasRouteOverlap bool
routeECMPFlag bool
routeOverlapFlag bool
)

if temp, ok := d.GetOkExists("route_ecmp_flag"); ok {
request.RouteECMPFlag = helper.Bool(temp.(bool))
routeECMPFlag = temp.(bool)
hasRouteECMP = true
}

if temp, ok := d.GetOkExists("route_overlap_flag"); ok {
request.RouteOverlapFlag = helper.Bool(temp.(bool))
routeOverlapFlag = temp.(bool)
hasRouteOverlap = true
}

err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyCcnAttribute(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}
if hasRouteECMP || hasRouteOverlap {
request := vpc.NewModifyCcnAttributeRequest()
request.CcnId = &info.ccnId
request.RouteECMPFlag = helper.Bool(routeECMPFlag)
request.RouteOverlapFlag = helper.Bool(routeOverlapFlag)
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyCcnAttribute(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}

if result == nil {
e = fmt.Errorf("update ModifyCcnAttribute failed")
return resource.NonRetryableError(e)
}
if result == nil {
e = fmt.Errorf("update ModifyCcnAttribute failed")
return resource.NonRetryableError(e)
}

_ = result
return nil
})
return nil
})

if err != nil {
log.Printf("[CRITAL]%s update ModifyCcnAttribute failed, reason:%s\n", logId, err.Error())
return err
if err != nil {
log.Printf("[CRITAL]%s update ModifyCcnAttribute failed, reason:%s\n", logId, err.Error())
return err
}
}

return resourceTencentCloudCcnRead(d, meta)
Expand Down
14 changes: 8 additions & 6 deletions tencentcloud/services/ccn/resource_tc_ccn.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Provides a resource to create a CCN instance.

~> **NOTE:** `route_overlap_flag` currently does not support setting to `false`.

Example Usage

Create a prepaid CCN
Create a PREPAID CCN

```hcl
resource "tencentcloud_ccn" "example" {
Expand All @@ -14,12 +16,12 @@ resource "tencentcloud_ccn" "example" {
route_ecmp_flag = true
route_overlap_flag = true
tags = {
createBy = "terraform"
createBy = "Terraform"
}
}
```

Create a post-paid regional export speed limit type CCN
Create a POSTPAID regional export speed limit type CCN

```hcl
resource "tencentcloud_ccn" "example" {
Expand All @@ -29,14 +31,14 @@ resource "tencentcloud_ccn" "example" {
charge_type = "POSTPAID"
bandwidth_limit_type = "OUTER_REGION_LIMIT"
route_ecmp_flag = false
route_overlap_flag = false
route_overlap_flag = true
tags = {
createBy = "terraform"
createBy = "Terraform"
}
}
```

Create a post-paid inter-regional rate limit type CNN
Create a POSTPAID inter-regional rate limit type CNN

```hcl
resource "tencentcloud_ccn" "example" {
Expand Down
18 changes: 10 additions & 8 deletions website/docs/r/ccn.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ description: |-

Provides a resource to create a CCN instance.

~> **NOTE:** `route_overlap_flag` currently does not support setting to `false`.

## Example Usage

### Create a prepaid CCN
### Create a PREPAID CCN

```hcl
resource "tencentcloud_ccn" "example" {
Expand All @@ -25,12 +27,12 @@ resource "tencentcloud_ccn" "example" {
route_ecmp_flag = true
route_overlap_flag = true
tags = {
createBy = "terraform"
createBy = "Terraform"
}
}
```

### Create a post-paid regional export speed limit type CCN
### Create a POSTPAID regional export speed limit type CCN

```hcl
resource "tencentcloud_ccn" "example" {
Expand All @@ -40,14 +42,14 @@ resource "tencentcloud_ccn" "example" {
charge_type = "POSTPAID"
bandwidth_limit_type = "OUTER_REGION_LIMIT"
route_ecmp_flag = false
route_overlap_flag = false
route_overlap_flag = true
tags = {
createBy = "terraform"
createBy = "Terraform"
}
}
```

### Create a post-paid inter-regional rate limit type CNN
### Create a POSTPAID inter-regional rate limit type CNN

```hcl
resource "tencentcloud_ccn" "example" {
Expand All @@ -68,8 +70,8 @@ The following arguments are supported:
* `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.
* `description` - (Optional, String) Description of CCN, and maximum length does not exceed 100 bytes.
* `qos` - (Optional, String, ForceNew) CCN service quality, 'PT': Platinum, 'AU': Gold, 'AG': Silver. The default is 'AU'.
* `route_ecmp_flag` - (Optional, Bool) Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled.
* `route_overlap_flag` - (Optional, Bool) Whether to enable the routing overlap function. `true`: enabled, `false`: disabled.
* `route_ecmp_flag` - (Optional, Bool) Whether to enable the equivalent routing function. `true`: enabled, `false`: disabled. Default is false.
* `route_overlap_flag` - (Optional, Bool) Whether to enable the routing overlap function. `true`: enabled, `false`: disabled. Default is true, cannot set to false.
* `tags` - (Optional, Map) Instance tag.

## Attributes Reference
Expand Down
Loading