@@ -69,6 +69,12 @@ func ResourceTencentCloudClbInstance() *schema.Resource {
6969 ValidateFunc : tccommon .ValidateStringLengthInRange (2 , 60 ),
7070 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." ,
7171 },
72+ "cluster_id" : {
73+ Type : schema .TypeString ,
74+ Optional : true ,
75+ ForceNew : true ,
76+ Description : "Cluster ID." ,
77+ },
7278 "address_ip_version" : {
7379 Type : schema .TypeString ,
7480 Optional : true ,
@@ -286,6 +292,10 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
286292 request .SubnetId = helper .String (v .(string ))
287293 }
288294
295+ if v , ok := d .GetOk ("cluster_id" ); ok {
296+ request .ClusterIds = []* string {helper .String (v .(string ))}
297+ }
298+
289299 //vip_isp
290300 if v , ok := d .GetOk ("vip_isp" ); ok {
291301 if networkType == CLB_NETWORK_TYPE_INTERNAL {
@@ -459,7 +469,6 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
459469 log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
460470 logId , sgRequest .GetAction (), sgRequest .ToJsonString (), sgResponse .ToJsonString ())
461471 requestId := * sgResponse .Response .RequestId
462-
463472 retryErr := waitForTaskFinish (requestId , meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ())
464473 if retryErr != nil {
465474 return tccommon .RetryError (errors .WithStack (retryErr ))
@@ -489,7 +498,6 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
489498 log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
490499 logId , logRequest .GetAction (), logRequest .ToJsonString (), logResponse .ToJsonString ())
491500 requestId := * logResponse .Response .RequestId
492-
493501 retryErr := waitForTaskFinish (requestId , meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ())
494502 if retryErr != nil {
495503 return tccommon .RetryError (errors .WithStack (retryErr ))
@@ -515,6 +523,7 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
515523 Region : & targetRegionInfoRegion ,
516524 VpcId : & targetRegionInfoVpcId ,
517525 }
526+
518527 mRequest := clb .NewModifyLoadBalancerAttributesRequest ()
519528 mRequest .LoadBalancerId = helper .String (clbId )
520529 mRequest .TargetRegionInfo = & targetRegionInfo
@@ -620,6 +629,10 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{
620629 _ = d .Set ("ipv6_mode" , instance .IPv6Mode )
621630 _ = d .Set ("address_ipv6" , instance .AddressIPv6 )
622631
632+ if instance .ClusterIds != nil && len (instance .ClusterIds ) > 0 {
633+ _ = d .Set ("cluster_id" , instance .ClusterIds [0 ])
634+ }
635+
623636 if instance .SlaType != nil {
624637 _ = d .Set ("sla_type" , instance .SlaType )
625638 }
@@ -686,7 +699,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
686699 )
687700
688701 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-
690702 for _ , v := range immutableArgs {
691703 if d .HasChange (v ) {
692704 return fmt .Errorf ("argument `%s` cannot be changed" , v )
@@ -801,7 +813,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
801813 param .LoadBalancerId = & clbId
802814 param .SlaType = helper .String (d .Get ("sla_type" ).(string ))
803815 slaRequest .LoadBalancerSla = []* clb.SlaUpdateParam {& param }
804-
805816 var taskId string
806817 err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
807818 result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ().ModifyLoadBalancerSla (slaRequest )
@@ -857,7 +868,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
857868 log .Printf ("[CRITAL]%s update CLB instance security_group failed, reason:%+v" , logId , err )
858869 return err
859870 }
860-
861871 }
862872
863873 if d .HasChange ("log_set_id" ) || d .HasChange ("log_topic_id" ) {
@@ -875,7 +885,6 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
875885 log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
876886 logId , logRequest .GetAction (), logRequest .ToJsonString (), logResponse .ToJsonString ())
877887 requestId := * logResponse .Response .RequestId
878-
879888 retryErr := waitForTaskFinish (requestId , meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseClbClient ())
880889 if retryErr != nil {
881890 return tccommon .RetryError (errors .WithStack (retryErr ))
@@ -976,6 +985,7 @@ func checkSameName(name string, meta interface{}) (flag bool, errRet error) {
976985 clbService = ClbService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
977986 )
978987
988+ flag = false
979989 params := make (map [string ]interface {})
980990 params ["clb_name" ] = name
981991 err := resource .Retry (tccommon .ReadRetryTimeout , func () * resource.RetryError {
0 commit comments