@@ -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 )
0 commit comments