Skip to content

Commit 8b7cd17

Browse files
authored
fix(vpc): [120966555] tencentcloud_vpn_connection add new fields (#2982)
* add * add * add
1 parent fa68f85 commit 8b7cd17

File tree

5 files changed

+319
-32
lines changed

5 files changed

+319
-32
lines changed

.changelog/2982.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_vpn_connection: add `negotiation_type`, `bgp_config`, `health_check_config` params
3+
```

tencentcloud/services/vpc/extension_vpc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,14 @@ const (
242242
ROUTE_TYPE_STATIC = "STATIC"
243243
ROUTE_TYPE_STATIC_ROUTE = "StaticRoute"
244244
ROUTE_TYPE_POLICY = "Policy"
245+
ROUTE_TYPE_BGP = "Bgp"
245246
)
246247

247248
var VPN_CONNECTION_ROUTE_TYPE = []string{
248249
ROUTE_TYPE_STATIC,
249250
ROUTE_TYPE_STATIC_ROUTE,
250251
ROUTE_TYPE_POLICY,
252+
ROUTE_TYPE_BGP,
251253
}
252254

253255
const (

tencentcloud/services/vpn/resource_tc_vpn_connection.go

Lines changed: 231 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,92 @@ func ResourceTencentCloudVpnConnection() *schema.Resource {
245245
Computed: true,
246246
ForceNew: true,
247247
ValidateFunc: tccommon.ValidateAllowedStringValue(svcvpc.VPN_CONNECTION_ROUTE_TYPE),
248-
Description: "Route type of the VPN connection. Valid value: `STATIC`, `StaticRoute`, `Policy`.",
248+
Description: "Route type of the VPN connection. Valid value: `STATIC`, `StaticRoute`, `Policy`, `Bgp`.",
249+
},
250+
"negotiation_type": {
251+
Type: schema.TypeString,
252+
Optional: true,
253+
Computed: true,
254+
Description: "The default negotiation type is `active`. Optional values: `active` (active negotiation), `passive` (passive negotiation), `flowTrigger` (traffic negotiation).",
255+
},
256+
// "route": {
257+
// Type: schema.TypeList,
258+
// Optional: true,
259+
// ForceNew: true,
260+
// MaxItems: 1,
261+
// Description: "Create channel routing information.",
262+
// Elem: &schema.Resource{
263+
// Schema: map[string]*schema.Schema{
264+
// "destination_cidr_block": {
265+
// Type: schema.TypeString,
266+
// Required: true,
267+
// Description: "Destination IDC network segment.",
268+
// },
269+
// "priority": {
270+
// Type: schema.TypeInt,
271+
// Optional: true,
272+
// Description: "Priority. Optional value [0, 100].",
273+
// },
274+
// },
275+
// },
276+
// },
277+
"bgp_config": {
278+
Type: schema.TypeList,
279+
Optional: true,
280+
Computed: true,
281+
ForceNew: true,
282+
MaxItems: 1,
283+
Description: "BGP config.",
284+
Elem: &schema.Resource{
285+
Schema: map[string]*schema.Schema{
286+
"tunnel_cidr": {
287+
Type: schema.TypeString,
288+
Required: true,
289+
Description: "BGP tunnel segment.",
290+
},
291+
"local_bgp_ip": {
292+
Type: schema.TypeString,
293+
Required: true,
294+
Description: "Cloud BGP address. It must be allocated from within the BGP tunnel network segment.",
295+
},
296+
"remote_bgp_ip": {
297+
Type: schema.TypeString,
298+
Required: true,
299+
Description: "User side BGP address. It must be allocated from within the BGP tunnel network segment.",
300+
},
301+
},
302+
},
303+
},
304+
"health_check_config": {
305+
Type: schema.TypeList,
306+
Optional: true,
307+
Computed: true,
308+
MaxItems: 1,
309+
Description: "VPN channel health check configuration.",
310+
Elem: &schema.Resource{
311+
Schema: map[string]*schema.Schema{
312+
"probe_type": {
313+
Type: schema.TypeString,
314+
Optional: true,
315+
Description: "Detection mode, default is `NQA`, cannot be modified.",
316+
},
317+
"probe_interval": {
318+
Type: schema.TypeInt,
319+
Optional: true,
320+
Description: "Detection interval, Tencent Cloud's interval between two health checks, range [1000-5000], Unit: ms.",
321+
},
322+
"probe_threshold": {
323+
Type: schema.TypeInt,
324+
Optional: true,
325+
Description: "Detection times, perform route switching after N consecutive health check failures, range [3-8], Unit: times.",
326+
},
327+
"probe_timeout": {
328+
Type: schema.TypeInt,
329+
Optional: true,
330+
Description: "Detection timeout, range [10-5000], Unit: ms.",
331+
},
332+
},
333+
},
249334
},
250335
"state": {
251336
Type: schema.TypeString,
@@ -329,6 +414,10 @@ func resourceTencentCloudVpnConnectionCreate(d *schema.ResourceData, meta interf
329414
request.RouteType = helper.String(v.(string))
330415
}
331416

417+
if v, ok := d.GetOk("negotiation_type"); ok {
418+
request.NegotiationType = helper.String(v.(string))
419+
}
420+
332421
//set up SecurityPolicyDatabases
333422
if v, ok := d.GetOk("security_group_policy"); ok {
334423
sgps := v.(*schema.Set).List()
@@ -411,6 +500,66 @@ func resourceTencentCloudVpnConnectionCreate(d *schema.ResourceData, meta interf
411500
request.HealthCheckRemoteIp = helper.String(v.(string))
412501
}
413502

503+
// if v, ok := d.GetOk("route"); ok {
504+
// for _, item := range v.([]interface{}) {
505+
// dMap := item.(map[string]interface{})
506+
// route := vpc.CreateVpnConnRoute{}
507+
// if v, ok := dMap["destination_cidr_block"]; ok {
508+
// route.DestinationCidrBlock = helper.String(v.(string))
509+
// }
510+
511+
// if v, ok := dMap["priority"]; ok {
512+
// route.Priority = helper.IntUint64(v.(int))
513+
// }
514+
515+
// request.Route = &route
516+
// }
517+
// }
518+
519+
if v, ok := d.GetOk("bgp_config"); ok {
520+
for _, item := range v.([]interface{}) {
521+
dMap := item.(map[string]interface{})
522+
bgpConfig := vpc.BgpConfig{}
523+
if v, ok := dMap["tunnel_cidr"]; ok {
524+
bgpConfig.TunnelCidr = helper.String(v.(string))
525+
}
526+
527+
if v, ok := dMap["local_bgp_ip"]; ok {
528+
bgpConfig.LocalBgpIp = helper.String(v.(string))
529+
}
530+
531+
if v, ok := dMap["remote_bgp_ip"]; ok {
532+
bgpConfig.RemoteBgpIp = helper.String(v.(string))
533+
}
534+
535+
request.BgpConfig = &bgpConfig
536+
}
537+
}
538+
539+
if v, ok := d.GetOk("health_check_config"); ok {
540+
for _, item := range v.([]interface{}) {
541+
dMap := item.(map[string]interface{})
542+
healthCheckConfig := vpc.HealthCheckConfig{}
543+
if v, ok := dMap["probe_type"]; ok {
544+
healthCheckConfig.ProbeType = helper.String(v.(string))
545+
}
546+
547+
if v, ok := dMap["probe_interval"]; ok {
548+
healthCheckConfig.ProbeInterval = helper.IntInt64(v.(int))
549+
}
550+
551+
if v, ok := dMap["probe_threshold"]; ok {
552+
healthCheckConfig.ProbeThreshold = helper.IntInt64(v.(int))
553+
}
554+
555+
if v, ok := dMap["probe_timeout"]; ok {
556+
healthCheckConfig.ProbeTimeout = helper.IntInt64(v.(int))
557+
}
558+
559+
request.HealthCheckConfig = &healthCheckConfig
560+
}
561+
}
562+
414563
var response *vpc.CreateVpnConnectionResponse
415564
err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
416565
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().CreateVpnConnection(request)
@@ -640,8 +789,54 @@ func resourceTencentCloudVpnConnectionRead(d *schema.ResourceData, meta interfac
640789
_ = d.Set("dpd_timeout", dpdTimeoutInt)
641790
}
642791

792+
if connection.NegotiationType != nil {
793+
_ = d.Set("negotiation_type", *connection.NegotiationType)
794+
}
795+
643796
_ = d.Set("dpd_action", *connection.DpdAction)
644797

798+
if connection.BgpConfig != nil {
799+
tmpList := make([]map[string]interface{}, 0)
800+
dMap := make(map[string]interface{})
801+
if connection.BgpConfig.TunnelCidr != nil {
802+
dMap["tunnel_cidr"] = *connection.BgpConfig.TunnelCidr
803+
}
804+
805+
if connection.BgpConfig.LocalBgpIp != nil {
806+
dMap["local_bgp_ip"] = *connection.BgpConfig.LocalBgpIp
807+
}
808+
809+
if connection.BgpConfig.RemoteBgpIp != nil {
810+
dMap["remote_bgp_ip"] = *connection.BgpConfig.RemoteBgpIp
811+
}
812+
813+
tmpList = append(tmpList, dMap)
814+
_ = d.Set("bgp_config", tmpList)
815+
}
816+
817+
if connection.HealthCheckConfig != nil {
818+
tmpList := make([]map[string]interface{}, 0)
819+
dMap := make(map[string]interface{})
820+
if connection.HealthCheckConfig.ProbeType != nil {
821+
dMap["probe_type"] = *connection.HealthCheckConfig.ProbeType
822+
}
823+
824+
if connection.HealthCheckConfig.ProbeInterval != nil {
825+
dMap["probe_interval"] = *connection.HealthCheckConfig.ProbeInterval
826+
}
827+
828+
if connection.HealthCheckConfig.ProbeThreshold != nil {
829+
dMap["probe_threshold"] = *connection.HealthCheckConfig.ProbeThreshold
830+
}
831+
832+
if connection.HealthCheckConfig.ProbeTimeout != nil {
833+
dMap["probe_timeout"] = *connection.HealthCheckConfig.ProbeTimeout
834+
}
835+
836+
tmpList = append(tmpList, dMap)
837+
_ = d.Set("health_check_config", tmpList)
838+
}
839+
645840
//tags
646841
tagService := svctag.NewTagService(meta.(tccommon.ProviderMeta).GetAPIV3Conn())
647842
region := meta.(tccommon.ProviderMeta).GetAPIV3Conn().Region
@@ -818,6 +1013,41 @@ func resourceTencentCloudVpnConnectionUpdate(d *schema.ResourceData, meta interf
8181013
request.IPSECOptionsSpecification = &ipsecOptionsSpecification
8191014
changeFlag = true
8201015
}
1016+
1017+
if d.HasChange("negotiation_type") {
1018+
if v, ok := d.GetOk("negotiation_type"); ok {
1019+
request.NegotiationType = helper.String(v.(string))
1020+
}
1021+
}
1022+
1023+
if d.HasChange("health_check_config") {
1024+
if v, ok := d.GetOk("health_check_config"); ok {
1025+
for _, item := range v.([]interface{}) {
1026+
dMap := item.(map[string]interface{})
1027+
healthCheckConfig := vpc.HealthCheckConfig{}
1028+
if v, ok := dMap["probe_type"]; ok {
1029+
healthCheckConfig.ProbeType = helper.String(v.(string))
1030+
}
1031+
1032+
if v, ok := dMap["probe_interval"]; ok {
1033+
healthCheckConfig.ProbeInterval = helper.IntInt64(v.(int))
1034+
}
1035+
1036+
if v, ok := dMap["probe_threshold"]; ok {
1037+
healthCheckConfig.ProbeThreshold = helper.IntInt64(v.(int))
1038+
}
1039+
1040+
if v, ok := dMap["probe_timeout"]; ok {
1041+
healthCheckConfig.ProbeTimeout = helper.IntInt64(v.(int))
1042+
}
1043+
1044+
request.HealthCheckConfig = &healthCheckConfig
1045+
}
1046+
1047+
changeFlag = true
1048+
}
1049+
}
1050+
8211051
if changeFlag {
8221052
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
8231053
_, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyVpnConnectionAttribute(request)

tencentcloud/services/vpn/resource_tc_vpn_connection.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,51 @@ Provides a resource to create a VPN connection.
33
Example Usage
44

55
```hcl
6-
resource "tencentcloud_vpn_connection" "foo" {
7-
name = "vpn_connection_test"
8-
vpc_id = "vpc-dk8zmwuf"
9-
vpn_gateway_id = "vpngw-8ccsnclt"
10-
customer_gateway_id = "cgw-xfqag"
11-
pre_share_key = "testt"
6+
resource "tencentcloud_vpn_connection" "example" {
7+
name = "tf-example"
8+
vpc_id = "vpc-6ccw0s5l"
9+
vpn_gateway_id = "vpngw-33p5vnwd"
10+
customer_gateway_id = "cgw-e503id2z"
11+
pre_share_key = "your_pre_share_key"
12+
route_type = "StaticRoute"
13+
negotiation_type = "flowTrigger"
14+
15+
# IKE setting
1216
ike_proto_encry_algorithm = "3DES-CBC"
1317
ike_proto_authen_algorithm = "SHA"
1418
ike_local_identity = "ADDRESS"
1519
ike_exchange_mode = "AGGRESSIVE"
16-
ike_local_address = "1.1.1.1"
20+
ike_local_address = "159.75.204.38"
1721
ike_remote_identity = "ADDRESS"
18-
ike_remote_address = "2.2.2.2"
22+
ike_remote_address = "109.244.60.154"
1923
ike_dh_group_name = "GROUP2"
20-
ike_sa_lifetime_seconds = 86401
21-
ipsec_encrypt_algorithm = "3DES-CBC"
22-
ipsec_integrity_algorithm = "SHA1"
23-
ipsec_sa_lifetime_seconds = 7200
24-
ipsec_pfs_dh_group = "NULL"
25-
ipsec_sa_lifetime_traffic = 2570
24+
ike_sa_lifetime_seconds = 86400
25+
26+
# IPSEC setting
27+
ipsec_encrypt_algorithm = "3DES-CBC"
28+
ipsec_integrity_algorithm = "SHA1"
29+
ipsec_sa_lifetime_seconds = 14400
30+
ipsec_pfs_dh_group = "NULL"
31+
ipsec_sa_lifetime_traffic = 4096000000
32+
33+
# health check setting
34+
enable_health_check = true
35+
health_check_local_ip = "169.254.227.187"
36+
health_check_remote_ip = "169.254.164.37"
37+
health_check_config {
38+
probe_type = "NQA"
39+
probe_interval = 5000
40+
probe_threshold = 3
41+
probe_timeout = 150
42+
}
2643
2744
security_group_policy {
2845
local_cidr_block = "172.16.0.0/16"
2946
remote_cidr_block = ["2.2.2.0/26", ]
3047
}
48+
3149
tags = {
32-
test = "testt"
50+
createBy = "Terraform"
3351
}
3452
}
3553
```

0 commit comments

Comments
 (0)