Skip to content
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/3664.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_vpc: support `enable_route_vpc_publish`
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tse v1.0.857
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.1.14
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.3.13
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.1.36
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.1.45
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wss v1.0.199
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674 h1:VsMV1/v
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tsf v1.0.674/go.mod h1:6+MWxaNR4y+spZHYNntulOyj628owTLuWmEFebJOWdA=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860 h1:vW2NgAHK4BfpZP3m92eUEKbIP+nu9bL8mnaM0dBHWM8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod v1.0.860/go.mod h1:uCkDh/AW/tb8JGq5b2kqLjqZuhCFR+6oTsq1SrrvT44=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.1.14 h1:RsontLM/fwcRJex/HlNj3/BGwh6HWuUjcgxeRnuL9KY=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.1.14/go.mod h1:qvuXI7MmzMaUBhGaQhGdZU7QLp3hKS53a3otvIz4CYg=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.3.13 h1:2Gs0PUF+MRGPJTM4apPE28jYgKQpiSLwHOO70n9lp84=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vpc v1.3.13/go.mod h1:4ZE3sBHqhPQ3ft3qHy9aJaoK0lcZ/+fyipP8ih9pN2Y=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.1.36 h1:d4Cjrt+VkS0OElToWZuojkj55z07ECvqfSyeyLOziF4=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/waf v1.1.36/go.mod h1:4ukz7/m3FarLnjn9UTX/Oc0cTWLZb82MKVLov0Ac4/k=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/wedata v1.1.45 h1:/hXcPg/N0Al6zn2EusGdskdeiyqSTRM9RbYqkiYCghs=
Expand Down
57 changes: 46 additions & 11 deletions tencentcloud/services/vpc/resource_tc_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ func ResourceTencentCloudVpcInstance() *schema.Resource {
Optional: true,
Description: "Tags of the VPC.",
},
"enable_route_vpc_publish": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
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.",
},
"enable_route_vpc_publish_ipv6": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
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.",
},

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

var (
name string
cidrBlock string
dnsServers = make([]string, 0, 4)
isMulticast bool
tags map[string]string
name string
cidrBlock string
dnsServers = make([]string, 0, 4)
isMulticast bool
tags map[string]string
enableRouteVpcPublish bool
enableRouteVpcPublishIpv6 bool
)
if temp, ok := d.GetOk("name"); ok {
name = temp.(string)
Expand Down Expand Up @@ -142,7 +156,16 @@ func resourceTencentCloudVpcInstanceCreate(d *schema.ResourceData, meta interfac
if temp := helper.GetTags(d, "tags"); len(temp) > 0 {
tags = temp
}
vpcId, _, err := vpcService.CreateVpc(ctx, name, cidrBlock, isMulticast, dnsServers, tags)

if temp, ok := d.GetOkExists("enable_route_vpc_publish"); ok {
enableRouteVpcPublish = temp.(bool)
}

if temp, ok := d.GetOkExists("enable_route_vpc_publish_ipv6"); ok {
enableRouteVpcPublishIpv6 = temp.(bool)
}

vpcId, _, err := vpcService.CreateVpc(ctx, name, cidrBlock, isMulticast, dnsServers, tags, enableRouteVpcPublish, enableRouteVpcPublishIpv6)
if err != nil {
return err
}
Expand Down Expand Up @@ -236,6 +259,8 @@ func resourceTencentCloudVpcInstanceRead(d *schema.ResourceData, meta interface{
_ = d.Set("assistant_cidrs", info.assistantCidrs)
_ = d.Set("docker_assistant_cidrs", info.dockerAssistantCidrs)
_ = d.Set("tags", tags)
_ = d.Set("enable_route_vpc_publish", info.enableRouteVpcPublish)
_ = d.Set("enable_route_vpc_publish_ipv6", info.enableRouteVpcPublishIpv6)

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

var (
name string
dnsServers = make([]string, 0, 4)
slice []interface{}
isMulticast bool
name string
dnsServers = make([]string, 0, 4)
slice []interface{}
isMulticast bool
enableRouteVpcPublish bool
enableRouteVpcPublishIpv6 bool
)

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

if err := vpcService.ModifyVpcAttribute(ctx, id, name, isMulticast, dnsServers); err != nil {
if temp, ok := d.GetOkExists("enable_route_vpc_publish"); ok {
enableRouteVpcPublish = temp.(bool)
}

if temp, ok := d.GetOkExists("enable_route_vpc_publish_ipv6"); ok {
enableRouteVpcPublishIpv6 = temp.(bool)
}

if err := vpcService.ModifyVpcAttribute(ctx, id, name, isMulticast, dnsServers, enableRouteVpcPublish, enableRouteVpcPublishIpv6); err != nil {
return err
}

Expand Down
24 changes: 20 additions & 4 deletions tencentcloud/services/vpc/resource_tc_vpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource "tencentcloud_vpc" "vpc" {
is_multicast = false

tags = {
"test" = "test"
createBy = "Terraform"
}
}
```
Expand All @@ -27,7 +27,23 @@ resource "tencentcloud_vpc" "vpc" {
assistant_cidrs = ["172.16.0.0/24"]

tags = {
"test" = "test"
createBy = "Terraform"
}
}
```

Enable route vpc publish

```hcl
resource "tencentcloud_vpc" "vpc" {
name = "tf-example"
cidr_block = "10.0.0.0/16"
dns_servers = ["119.29.29.29", "8.8.8.8"]
is_multicast = false
enable_route_vpc_publish = true

tags = {
createBy = "Terraform"
}
}
```
Expand All @@ -37,5 +53,5 @@ Import
Vpc instance can be imported, e.g.

```
$ terraform import tencentcloud_vpc.test vpc-id
```
$ terraform import tencentcloud_vpc.vpc vpc-8vazrwjv
```
40 changes: 28 additions & 12 deletions tencentcloud/services/vpc/service_tencentcloud_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ var eipUnattachLocker = &sync.Mutex{}
/* For Adun Sake please DO NOT Declare the redundant Type STRUCT!! */
// VPC basic information
type VpcBasicInfo struct {
vpcId string
name string
cidr string
isMulticast bool
isDefault bool
dnsServers []string
createTime string
tags []*vpc.Tag
assistantCidrs []string
dockerAssistantCidrs []string
vpcId string
name string
cidr string
isMulticast bool
isDefault bool
dnsServers []string
createTime string
tags []*vpc.Tag
assistantCidrs []string
dockerAssistantCidrs []string
enableRouteVpcPublish bool
enableRouteVpcPublishIpv6 bool
}

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

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

logId := tccommon.GetLogId(ctx)
request := vpc.NewCreateVpcRequest()
Expand Down Expand Up @@ -308,6 +310,9 @@ func (me *VpcService) CreateVpc(ctx context.Context, name, cidr string,
}
}

request.EnableRouteVpcPublish = &enableRouteVpcPublish
request.EnableRouteVpcPublishIpv6 = &enableRouteVpcPublishIpv6

var response *vpc.CreateVpcResponse
if err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
ratelimit.Check(request.GetAction())
Expand Down Expand Up @@ -476,6 +481,14 @@ getMoreData:
basicInfo.tags = item.TagSet
}

if item.EnableRouteVpcPublish != nil {
basicInfo.enableRouteVpcPublish = *item.EnableRouteVpcPublish
}

if item.EnableRouteVpcPublishIpv6 != nil {
basicInfo.enableRouteVpcPublishIpv6 = *item.EnableRouteVpcPublishIpv6
}

infos = append(infos, basicInfo)
}
goto getMoreData
Expand Down Expand Up @@ -629,7 +642,7 @@ getMoreData:
goto getMoreData
}

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

request.EnableRouteVpcPublish = &enableRouteVpcPublish
request.EnableRouteVpcPublishIpv6 = &enableRouteVpcPublishIpv6

if err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
ratelimit.Check(request.GetAction())
_, err := me.client.UseVpcClient().ModifyVpcAttribute(request)
Expand Down
Loading
Loading