@@ -69,6 +69,12 @@ func ResourceTencentCloudClbInstance() *schema.Resource {
69
69
ValidateFunc : tccommon .ValidateStringLengthInRange (2 , 60 ),
70
70
Description : "In the case of purchasing a `INTERNAL` clb instance, the subnet id must be specified. The VIP of the `INTERNAL` clb instance will be generated from this subnet." ,
71
71
},
72
+ "cluster_id" : {
73
+ Type : schema .TypeString ,
74
+ Optional : true ,
75
+ ForceNew : true ,
76
+ Description : "Cluster ID." ,
77
+ },
72
78
"address_ip_version" : {
73
79
Type : schema .TypeString ,
74
80
Optional : true ,
@@ -286,6 +292,10 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
286
292
request .SubnetId = helper .String (v .(string ))
287
293
}
288
294
295
+ if v , ok := d .GetOk ("cluster_id" ); ok {
296
+ request .ClusterIds = []* string {helper .String (v .(string ))}
297
+ }
298
+
289
299
//vip_isp
290
300
if v , ok := d .GetOk ("vip_isp" ); ok {
291
301
if networkType == CLB_NETWORK_TYPE_INTERNAL {
@@ -459,7 +469,6 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
459
469
log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
460
470
logId , sgRequest .GetAction (), sgRequest .ToJsonString (), sgResponse .ToJsonString ())
461
471
requestId := * sgResponse .Response .RequestId
462
-
463
472
retryErr := waitForTaskFinish (requestId , meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ())
464
473
if retryErr != nil {
465
474
return tccommon .RetryError (errors .WithStack (retryErr ))
@@ -489,7 +498,6 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
489
498
log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
490
499
logId , logRequest .GetAction (), logRequest .ToJsonString (), logResponse .ToJsonString ())
491
500
requestId := * logResponse .Response .RequestId
492
-
493
501
retryErr := waitForTaskFinish (requestId , meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ())
494
502
if retryErr != nil {
495
503
return tccommon .RetryError (errors .WithStack (retryErr ))
@@ -515,6 +523,7 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
515
523
Region : & targetRegionInfoRegion ,
516
524
VpcId : & targetRegionInfoVpcId ,
517
525
}
526
+
518
527
mRequest := clb .NewModifyLoadBalancerAttributesRequest ()
519
528
mRequest .LoadBalancerId = helper .String (clbId )
520
529
mRequest .TargetRegionInfo = & targetRegionInfo
@@ -620,6 +629,10 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{
620
629
_ = d .Set ("ipv6_mode" , instance .IPv6Mode )
621
630
_ = d .Set ("address_ipv6" , instance .AddressIPv6 )
622
631
632
+ if instance .ClusterIds != nil && len (instance .ClusterIds ) > 0 {
633
+ _ = d .Set ("cluster_id" , instance .ClusterIds [0 ])
634
+ }
635
+
623
636
if instance .SlaType != nil {
624
637
_ = d .Set ("sla_type" , instance .SlaType )
625
638
}
@@ -686,7 +699,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
686
699
)
687
700
688
701
immutableArgs := []string {"snat_ips" , "dynamic_vip" , "master_zone_id" , "slave_zone_id" , "vpc_id" , "subnet_id" , "address_ip_version" , "bandwidth_package_id" , "zone_id" }
689
-
690
702
for _ , v := range immutableArgs {
691
703
if d .HasChange (v ) {
692
704
return fmt .Errorf ("argument `%s` cannot be changed" , v )
@@ -801,7 +813,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
801
813
param .LoadBalancerId = & clbId
802
814
param .SlaType = helper .String (d .Get ("sla_type" ).(string ))
803
815
slaRequest .LoadBalancerSla = []* clb.SlaUpdateParam {& param }
804
-
805
816
var taskId string
806
817
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
807
818
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ().ModifyLoadBalancerSla (slaRequest )
@@ -857,7 +868,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
857
868
log .Printf ("[CRITAL]%s update CLB instance security_group failed, reason:%+v" , logId , err )
858
869
return err
859
870
}
860
-
861
871
}
862
872
863
873
if d .HasChange ("log_set_id" ) || d .HasChange ("log_topic_id" ) {
@@ -875,7 +885,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
875
885
log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
876
886
logId , logRequest .GetAction (), logRequest .ToJsonString (), logResponse .ToJsonString ())
877
887
requestId := * logResponse .Response .RequestId
878
-
879
888
retryErr := waitForTaskFinish (requestId , meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ())
880
889
if retryErr != nil {
881
890
return tccommon .RetryError (errors .WithStack (retryErr ))
@@ -976,6 +985,7 @@ func checkSameName(name string, meta interface{}) (flag bool, errRet error) {
976
985
clbService = ClbService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
977
986
)
978
987
988
+ flag = false
979
989
params := make (map [string ]interface {})
980
990
params ["clb_name" ] = name
981
991
err := resource .Retry (tccommon .ReadRetryTimeout , func () * resource.RetryError {
0 commit comments