Skip to content

Commit 650a1a8

Browse files
committed
add
1 parent c290d73 commit 650a1a8

File tree

4 files changed

+46
-62
lines changed

4 files changed

+46
-62
lines changed

tencentcloud/services/vpc/resource_tc_route_table_entry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ func resourceTencentCloudVpcRouteEntryCreate(d *schema.ResourceData, meta interf
133133
request := vpc.NewDisableRoutesRequest()
134134
request.RouteTableId = &routeTableId
135135
request.RouteIds = []*uint64{helper.Int64Uint64(entryId)}
136-
err := service.DisableRoutes(ctx, request)
136+
err = service.DisableRoutes(ctx, request)
137137
if err != nil {
138138
return err
139139
}
140140
}
141141

142-
return nil
142+
return resourceTencentCloudVpcRouteEntryRead(d, meta)
143143
}
144144

145145
func resourceTencentCloudVpcRouteEntryRead(d *schema.ResourceData, meta interface{}) error {

tencentcloud/services/vpc/resource_tc_route_table_entry.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,42 @@ Example Usage
44

55
```hcl
66
variable "availability_zone" {
7-
default = "na-siliconvalley-1"
7+
default = "ap-guangzhou-4"
88
}
99
10-
resource "tencentcloud_vpc" "foo" {
11-
name = "ci-temp-test"
10+
# create vpc
11+
resource "tencentcloud_vpc" "vpc" {
12+
name = "vpc"
1213
cidr_block = "10.0.0.0/16"
1314
}
1415
15-
resource "tencentcloud_subnet" "foo" {
16-
vpc_id = tencentcloud_vpc.foo.id
17-
name = "terraform test subnet"
16+
# create subnet
17+
resource "tencentcloud_subnet" "subnet" {
18+
vpc_id = tencentcloud_vpc.vpc.id
19+
name = "subnet"
1820
cidr_block = "10.0.12.0/24"
1921
availability_zone = var.availability_zone
20-
route_table_id = tencentcloud_route_table.foo.id
22+
route_table_id = tencentcloud_route_table.example.id
2123
}
2224
23-
resource "tencentcloud_route_table" "foo" {
24-
vpc_id = tencentcloud_vpc.foo.id
25-
name = "ci-temp-test-rt"
25+
# create route table
26+
resource "tencentcloud_route_table" "example" {
27+
vpc_id = tencentcloud_vpc.vpc.id
28+
name = "tf-example"
2629
}
2730
28-
resource "tencentcloud_route_table_entry" "instance" {
29-
route_table_id = tencentcloud_route_table.foo.id
31+
# create route table entry
32+
resource "tencentcloud_route_table_entry" "example" {
33+
route_table_id = tencentcloud_route_table.example.id
3034
destination_cidr_block = "10.4.4.0/24"
3135
next_type = "EIP"
3236
next_hub = "0"
33-
description = "ci-test-route-table-entry"
37+
description = "describe"
3438
}
3539
40+
# output
3641
output "item_id" {
37-
value = tencentcloud_route_table_entry.instance.route_item_id
42+
value = tencentcloud_route_table_entry.example.route_item_id
3843
}
3944
```
4045

@@ -43,5 +48,5 @@ Import
4348
Route table entry can be imported using the id, e.g.
4449

4550
```
46-
$ terraform import tencentcloud_route_table_entry.foo 83517.rtb-mlhpg09u
47-
```
51+
$ terraform import tencentcloud_route_table_entry.example 3065857.rtb-b050fg94
52+
```

tencentcloud/services/vpc/service_tencentcloud_vpc.go

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"strconv"
1313
"strings"
1414
"sync"
15-
"time"
1615

1716
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
1817

@@ -1174,36 +1173,11 @@ func (me *VpcService) CreateRoutes(ctx context.Context,
11741173
return
11751174
}
11761175

1177-
entryId, errRet = me.GetRouteId(ctx, routeTableId, destinationCidrBlock, nextType, nextHub, description)
1178-
1179-
if errRet != nil {
1180-
time.Sleep(3 * time.Second)
1181-
entryId, errRet = me.GetRouteId(ctx, routeTableId, destinationCidrBlock, nextType, nextHub, description)
1182-
}
1183-
1184-
if errRet != nil {
1185-
time.Sleep(5 * time.Second)
1186-
entryId, errRet = me.GetRouteId(ctx, routeTableId, destinationCidrBlock, nextType, nextHub, description)
1176+
if response == nil {
1177+
return
11871178
}
11881179

1189-
/*
1190-
if *(response.Response.TotalCount) != 1 {
1191-
errRet = fmt.Errorf("CreateRoutes return %d routeTable . but we only request 1.", *response.Response.TotalCount)
1192-
return
1193-
}
1194-
1195-
if len(response.Response.RouteTableSet) != 1 {
1196-
errRet = fmt.Errorf("CreateRoutes return %d routeTable info . but we only request 1.", len(response.Response.RouteTableSet))
1197-
return
1198-
}
1199-
1200-
if len(response.Response.RouteTableSet[0].RouteSet) != 1 {
1201-
errRet = fmt.Errorf("CreateRoutes return %d routeTableSet info . but we only create 1.", len(response.Response.RouteTableSet[0].RouteSet))
1202-
return
1203-
}
1204-
1205-
entryId = int64(*response.Response.RouteTableSet[0].RouteSet[0].RouteId)
1206-
*/
1180+
entryId = int64(*response.Response.RouteTableSet[0].RouteSet[0].RouteId)
12071181

12081182
return
12091183
}

website/docs/r/route_table_entry.html.markdown

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,42 @@ Provides a resource to create an entry of a routing table.
1515

1616
```hcl
1717
variable "availability_zone" {
18-
default = "na-siliconvalley-1"
18+
default = "ap-guangzhou-4"
1919
}
2020
21-
resource "tencentcloud_vpc" "foo" {
22-
name = "ci-temp-test"
21+
# create vpc
22+
resource "tencentcloud_vpc" "vpc" {
23+
name = "vpc"
2324
cidr_block = "10.0.0.0/16"
2425
}
2526
26-
resource "tencentcloud_subnet" "foo" {
27-
vpc_id = tencentcloud_vpc.foo.id
28-
name = "terraform test subnet"
27+
# create subnet
28+
resource "tencentcloud_subnet" "subnet" {
29+
vpc_id = tencentcloud_vpc.vpc.id
30+
name = "subnet"
2931
cidr_block = "10.0.12.0/24"
3032
availability_zone = var.availability_zone
31-
route_table_id = tencentcloud_route_table.foo.id
33+
route_table_id = tencentcloud_route_table.example.id
3234
}
3335
34-
resource "tencentcloud_route_table" "foo" {
35-
vpc_id = tencentcloud_vpc.foo.id
36-
name = "ci-temp-test-rt"
36+
# create route table
37+
resource "tencentcloud_route_table" "example" {
38+
vpc_id = tencentcloud_vpc.vpc.id
39+
name = "tf-example"
3740
}
3841
39-
resource "tencentcloud_route_table_entry" "instance" {
40-
route_table_id = tencentcloud_route_table.foo.id
42+
# create route table entry
43+
resource "tencentcloud_route_table_entry" "example" {
44+
route_table_id = tencentcloud_route_table.example.id
4145
destination_cidr_block = "10.4.4.0/24"
4246
next_type = "EIP"
4347
next_hub = "0"
44-
description = "ci-test-route-table-entry"
48+
description = "describe"
4549
}
4650
51+
# output
4752
output "item_id" {
48-
value = tencentcloud_route_table_entry.instance.route_item_id
53+
value = tencentcloud_route_table_entry.example.route_item_id
4954
}
5055
```
5156

@@ -73,6 +78,6 @@ In addition to all arguments above, the following attributes are exported:
7378
Route table entry can be imported using the id, e.g.
7479

7580
```
76-
$ terraform import tencentcloud_route_table_entry.foo 83517.rtb-mlhpg09u
81+
$ terraform import tencentcloud_route_table_entry.example 3065857.rtb-b050fg94
7782
```
7883

0 commit comments

Comments
 (0)