Skip to content

Commit da6897e

Browse files
tongyimingmikatong
andauthored
ccn attachment add param routeid (#2053)
* ccn attachment add param routeid * add changelog * update --------- Co-authored-by: mikatong <mikatong@tencent.com>
1 parent e71e2f0 commit da6897e

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

.changelog/2053.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_attachment: support `route_ids` fields
3+
```

tencentcloud/resource_tc_ccn_attachment.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ func resourceTencentCloudCcnAttachment() *schema.Resource {
125125
},
126126
Description: "A network address block of the instance that is attached.",
127127
},
128+
"route_ids": {
129+
Type: schema.TypeList,
130+
Computed: true,
131+
Elem: &schema.Schema{
132+
Type: schema.TypeString,
133+
},
134+
Description: "Route id list.",
135+
},
128136
},
129137
}
130138
}
@@ -277,6 +285,30 @@ func resourceTencentCloudCcnAttachmentRead(d *schema.ResourceData, meta interfac
277285
if err != nil {
278286
return err
279287
}
288+
289+
err = resource.Retry(readRetryTimeout, func() *resource.RetryError {
290+
request := vpc.NewDescribeCcnRoutesRequest()
291+
request.CcnId = &ccnId
292+
293+
response, e := meta.(*TencentCloudClient).apiV3Conn.UseVpcClient().DescribeCcnRoutes(request)
294+
if e != nil {
295+
return retryError(e)
296+
}
297+
routeIds := make([]string, 0)
298+
if response != nil && response.Response != nil && len(response.Response.RouteSet) > 0 {
299+
for _, route := range response.Response.RouteSet {
300+
routeIds = append(routeIds, *route.RouteId)
301+
}
302+
303+
}
304+
_ = d.Set("route_ids", routeIds)
305+
306+
return nil
307+
})
308+
if err != nil {
309+
return err
310+
}
311+
280312
return nil
281313
}
282314

tencentcloud/resource_tc_ccn_attachment_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1111
)
1212

13-
func TestAccTencentCloudCcnV3AttachmentBasic(t *testing.T) {
13+
func TestAccTencentCloudCcnAttachmentResource(t *testing.T) {
1414
t.Parallel()
1515
keyName := "tencentcloud_ccn_attachment.attachment"
1616
keyNameVpngw := "tencentcloud_ccn_attachment.vpngw_ccn_attachment"
@@ -43,6 +43,7 @@ func TestAccTencentCloudCcnV3AttachmentBasic(t *testing.T) {
4343
resource.TestCheckResourceAttrSet(keyNameVpngw, "state"),
4444
resource.TestCheckResourceAttrSet(keyNameVpngw, "attached_time"),
4545
resource.TestCheckResourceAttrSet(keyNameVpngw, "cidr_block.#"),
46+
resource.TestCheckResourceAttrSet(keyNameVpngw, "route_ids.#"),
4647
),
4748
},
4849
},

website/docs/r/ccn_attachment.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ In addition to all arguments above, the following attributes are exported:
7373
* `id` - ID of the resource.
7474
* `attached_time` - Time of attaching.
7575
* `cidr_block` - A network address block of the instance that is attached.
76+
* `route_ids` - Route id list.
7677
* `state` - States of instance is attached. Valid values: `PENDING`, `ACTIVE`, `EXPIRED`, `REJECTED`, `DELETED`, `FAILED`, `ATTACHING`, `DETACHING` and `DETACHFAILED`. `FAILED` means asynchronous forced disassociation after 2 hours. `DETACHFAILED` means asynchronous forced disassociation after 2 hours.
7778

7879

0 commit comments

Comments
 (0)