Skip to content

Commit 9b5a2bb

Browse files
authored
fix(vpc): [129432559] tencentcloud_vpc support enable_route_vpc_publish (#3664)
* add * add
1 parent 46d436e commit 9b5a2bb

File tree

11 files changed

+3145
-205
lines changed

11 files changed

+3145
-205
lines changed

.changelog/3664.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_vpc: support `enable_route_vpc_publish`
3+
```

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ require (
9696
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857
9797
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674
9898
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860
99-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.1.14
99+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.3.13
100100
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.1.36
101101
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.1.45
102102
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674 h1:VsMV1/v
10601060
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674/go.mod h1:6+MWxaNR4y+spZHYNntulOyj628owTLuWmEFebJOWdA=
10611061
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860 h1:vW2NgAHK4BfpZP3m92eUEKbIP+nu9bL8mnaM0dBHWM8=
10621062
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860/go.mod h1:uCkDh/AW/tb8JGq5b2kqLjqZuhCFR+6oTsq1SrrvT44=
1063-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.1.14 h1:RsontLM/fwcRJex/HlNj3/BGwh6HWuUjcgxeRnuL9KY=
1064-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.1.14/go.mod h1:qvuXI7MmzMaUBhGaQhGdZU7QLp3hKS53a3otvIz4CYg=
1063+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.3.13 h1:2Gs0PUF+MRGPJTM4apPE28jYgKQpiSLwHOO70n9lp84=
1064+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.3.13/go.mod h1:4ZE3sBHqhPQ3ft3qHy9aJaoK0lcZ/+fyipP8ih9pN2Y=
10651065
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.1.36 h1:d4Cjrt+VkS0OElToWZuojkj55z07ECvqfSyeyLOziF4=
10661066
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.1.36/go.mod h1:4ukz7/m3FarLnjn9UTX/Oc0cTWLZb82MKVLov0Ac4/k=
10671067
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.1.45 h1:/hXcPg/N0Al6zn2EusGdskdeiyqSTRM9RbYqkiYCghs=

tencentcloud/services/vpc/resource_tc_vpc.go

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ func ResourceTencentCloudVpcInstance() *schema.Resource {
8080
Optional: true,
8181
Description: "Tags of the VPC.",
8282
},
83+
"enable_route_vpc_publish": {
84+
Type: schema.TypeBool,
85+
Optional: true,
86+
Computed: true,
87+
Description: "Vpc association with CCN route publish policy. true: enables cidr route publishing. false: enables subnet route publishing. default is subnet route publishing when creating a vpc. to select cidr route publishing, submit a ticket for adding to allowlist.",
88+
},
89+
"enable_route_vpc_publish_ipv6": {
90+
Type: schema.TypeBool,
91+
Optional: true,
92+
Computed: true,
93+
Description: "Vpc association with CCN IPV6 route publish policy. true: enables cidr route publishing. false: enables subnet route publishing. default is subnet route publishing when creating a vpc. to select cidr route publishing, submit a ticket for adding to allowlist.",
94+
},
8395

8496
// Computed values
8597
"is_default": {
@@ -110,11 +122,13 @@ func resourceTencentCloudVpcInstanceCreate(d *schema.ResourceData, meta interfac
110122
vpcService := VpcService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
111123

112124
var (
113-
name string
114-
cidrBlock string
115-
dnsServers = make([]string, 0, 4)
116-
isMulticast bool
117-
tags map[string]string
125+
name string
126+
cidrBlock string
127+
dnsServers = make([]string, 0, 4)
128+
isMulticast bool
129+
tags map[string]string
130+
enableRouteVpcPublish bool
131+
enableRouteVpcPublishIpv6 bool
118132
)
119133
if temp, ok := d.GetOk("name"); ok {
120134
name = temp.(string)
@@ -142,7 +156,16 @@ func resourceTencentCloudVpcInstanceCreate(d *schema.ResourceData, meta interfac
142156
if temp := helper.GetTags(d, "tags"); len(temp) > 0 {
143157
tags = temp
144158
}
145-
vpcId, _, err := vpcService.CreateVpc(ctx, name, cidrBlock, isMulticast, dnsServers, tags)
159+
160+
if temp, ok := d.GetOkExists("enable_route_vpc_publish"); ok {
161+
enableRouteVpcPublish = temp.(bool)
162+
}
163+
164+
if temp, ok := d.GetOkExists("enable_route_vpc_publish_ipv6"); ok {
165+
enableRouteVpcPublishIpv6 = temp.(bool)
166+
}
167+
168+
vpcId, _, err := vpcService.CreateVpc(ctx, name, cidrBlock, isMulticast, dnsServers, tags, enableRouteVpcPublish, enableRouteVpcPublishIpv6)
146169
if err != nil {
147170
return err
148171
}
@@ -236,6 +259,8 @@ func resourceTencentCloudVpcInstanceRead(d *schema.ResourceData, meta interface{
236259
_ = d.Set("assistant_cidrs", info.assistantCidrs)
237260
_ = d.Set("docker_assistant_cidrs", info.dockerAssistantCidrs)
238261
_ = d.Set("tags", tags)
262+
_ = d.Set("enable_route_vpc_publish", info.enableRouteVpcPublish)
263+
_ = d.Set("enable_route_vpc_publish_ipv6", info.enableRouteVpcPublishIpv6)
239264

240265
return nil
241266
})
@@ -258,10 +283,12 @@ func resourceTencentCloudVpcInstanceUpdate(d *schema.ResourceData, meta interfac
258283
d.Partial(true)
259284

260285
var (
261-
name string
262-
dnsServers = make([]string, 0, 4)
263-
slice []interface{}
264-
isMulticast bool
286+
name string
287+
dnsServers = make([]string, 0, 4)
288+
slice []interface{}
289+
isMulticast bool
290+
enableRouteVpcPublish bool
291+
enableRouteVpcPublishIpv6 bool
265292
)
266293

267294
old, now := d.GetChange("name")
@@ -297,7 +324,15 @@ func resourceTencentCloudVpcInstanceUpdate(d *schema.ResourceData, meta interfac
297324
isMulticast = old.(bool)
298325
}
299326

300-
if err := vpcService.ModifyVpcAttribute(ctx, id, name, isMulticast, dnsServers); err != nil {
327+
if temp, ok := d.GetOkExists("enable_route_vpc_publish"); ok {
328+
enableRouteVpcPublish = temp.(bool)
329+
}
330+
331+
if temp, ok := d.GetOkExists("enable_route_vpc_publish_ipv6"); ok {
332+
enableRouteVpcPublishIpv6 = temp.(bool)
333+
}
334+
335+
if err := vpcService.ModifyVpcAttribute(ctx, id, name, isMulticast, dnsServers, enableRouteVpcPublish, enableRouteVpcPublishIpv6); err != nil {
301336
return err
302337
}
303338

tencentcloud/services/vpc/resource_tc_vpc.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resource "tencentcloud_vpc" "vpc" {
1212
is_multicast = false
1313
1414
tags = {
15-
"test" = "test"
15+
createBy = "Terraform"
1616
}
1717
}
1818
```
@@ -27,7 +27,23 @@ resource "tencentcloud_vpc" "vpc" {
2727
assistant_cidrs = ["172.16.0.0/24"]
2828
2929
tags = {
30-
"test" = "test"
30+
createBy = "Terraform"
31+
}
32+
}
33+
```
34+
35+
Enable route vpc publish
36+
37+
```hcl
38+
resource "tencentcloud_vpc" "vpc" {
39+
name = "tf-example"
40+
cidr_block = "10.0.0.0/16"
41+
dns_servers = ["119.29.29.29", "8.8.8.8"]
42+
is_multicast = false
43+
enable_route_vpc_publish = true
44+
45+
tags = {
46+
createBy = "Terraform"
3147
}
3248
}
3349
```
@@ -37,5 +53,5 @@ Import
3753
Vpc instance can be imported, e.g.
3854

3955
```
40-
$ terraform import tencentcloud_vpc.test vpc-id
41-
```
56+
$ terraform import tencentcloud_vpc.vpc vpc-8vazrwjv
57+
```

tencentcloud/services/vpc/service_tencentcloud_vpc.go

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ var eipUnattachLocker = &sync.Mutex{}
3131
/* For Adun Sake please DO NOT Declare the redundant Type STRUCT!! */
3232
// VPC basic information
3333
type VpcBasicInfo struct {
34-
vpcId string
35-
name string
36-
cidr string
37-
isMulticast bool
38-
isDefault bool
39-
dnsServers []string
40-
createTime string
41-
tags []*vpc.Tag
42-
assistantCidrs []string
43-
dockerAssistantCidrs []string
34+
vpcId string
35+
name string
36+
cidr string
37+
isMulticast bool
38+
isDefault bool
39+
dnsServers []string
40+
createTime string
41+
tags []*vpc.Tag
42+
assistantCidrs []string
43+
dockerAssistantCidrs []string
44+
enableRouteVpcPublish bool
45+
enableRouteVpcPublishIpv6 bool
4446
}
4547

4648
func (info VpcBasicInfo) VpcId() string {
@@ -274,7 +276,7 @@ func (me *VpcService) fillFilter(ins []*vpc.Filter, key, value string) (outs []*
274276

275277
// ////////api
276278
func (me *VpcService) CreateVpc(ctx context.Context, name, cidr string,
277-
isMulticast bool, dnsServers []string, tags map[string]string) (vpcId string, isDefault bool, errRet error) {
279+
isMulticast bool, dnsServers []string, tags map[string]string, enableRouteVpcPublish bool, enableRouteVpcPublishIpv6 bool) (vpcId string, isDefault bool, errRet error) {
278280

279281
logId := tccommon.GetLogId(ctx)
280282
request := vpc.NewCreateVpcRequest()
@@ -308,6 +310,9 @@ func (me *VpcService) CreateVpc(ctx context.Context, name, cidr string,
308310
}
309311
}
310312

313+
request.EnableRouteVpcPublish = &enableRouteVpcPublish
314+
request.EnableRouteVpcPublishIpv6 = &enableRouteVpcPublishIpv6
315+
311316
var response *vpc.CreateVpcResponse
312317
if err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
313318
ratelimit.Check(request.GetAction())
@@ -476,6 +481,14 @@ getMoreData:
476481
basicInfo.tags = item.TagSet
477482
}
478483

484+
if item.EnableRouteVpcPublish != nil {
485+
basicInfo.enableRouteVpcPublish = *item.EnableRouteVpcPublish
486+
}
487+
488+
if item.EnableRouteVpcPublishIpv6 != nil {
489+
basicInfo.enableRouteVpcPublishIpv6 = *item.EnableRouteVpcPublishIpv6
490+
}
491+
479492
infos = append(infos, basicInfo)
480493
}
481494
goto getMoreData
@@ -629,7 +642,7 @@ getMoreData:
629642
goto getMoreData
630643
}
631644

632-
func (me *VpcService) ModifyVpcAttribute(ctx context.Context, vpcId, name string, isMulticast bool, dnsServers []string) (errRet error) {
645+
func (me *VpcService) ModifyVpcAttribute(ctx context.Context, vpcId, name string, isMulticast bool, dnsServers []string, enableRouteVpcPublish bool, enableRouteVpcPublishIpv6 bool) (errRet error) {
633646
logId := tccommon.GetLogId(ctx)
634647
request := vpc.NewModifyVpcAttributeRequest()
635648
defer func() {
@@ -651,6 +664,9 @@ func (me *VpcService) ModifyVpcAttribute(ctx context.Context, vpcId, name string
651664
var enableMulticast = map[bool]string{true: "true", false: "false"}[isMulticast]
652665
request.EnableMulticast = &enableMulticast
653666

667+
request.EnableRouteVpcPublish = &enableRouteVpcPublish
668+
request.EnableRouteVpcPublishIpv6 = &enableRouteVpcPublishIpv6
669+
654670
if err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
655671
ratelimit.Check(request.GetAction())
656672
_, err := me.client.UseVpcClient().ModifyVpcAttribute(request)

0 commit comments

Comments
 (0)