@@ -73,6 +73,18 @@ func resourceTencentCloudCkafkaInstance() *schema.Resource {
7373 Required : true ,
7474 ForceNew : true ,
7575 Description : "Available zone id." ,
76+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
77+ multiZone := d .Get ("multi_zone_flag" ).(bool )
78+ zoneId := d .Get ("zone_id" ).(int )
79+ v , ok := d .GetOk ("zone_ids" )
80+
81+ if ! multiZone || ! ok {
82+ return old == new
83+ }
84+
85+ zoneIds := v .(* schema.Set )
86+ return zoneIds .Contains (zoneId )
87+ },
7688 },
7789 "period" : {
7890 Type : schema .TypeInt ,
@@ -136,6 +148,20 @@ func resourceTencentCloudCkafkaInstance() *schema.Resource {
136148 ForceNew : true ,
137149 Description : "Partition size, the professional version does not need set." ,
138150 },
151+ "multi_zone_flag" : {
152+ Type : schema .TypeBool ,
153+ Optional : true ,
154+ ForceNew : true ,
155+ Description : "Indicates whether the instance is multi zones. NOTE: if set to `true`, `zone_ids` must set together." ,
156+ },
157+ "zone_ids" : {
158+ Type : schema .TypeSet ,
159+ Optional : true ,
160+ ForceNew : true ,
161+ Description : "List of available zone id. NOTE: this argument must set together with `multi_zone_flag`." ,
162+ RequiredWith : []string {"multi_zone_flag" },
163+ Elem : & schema.Schema {Type : schema .TypeInt },
164+ },
139165 "tags" : {
140166 Type : schema .TypeList ,
141167 Optional : true ,
@@ -261,7 +287,6 @@ func resourceTencentCloudCkafkaInstanceCreate(d *schema.ResourceData, meta inter
261287 request .ZoneId = & zoneId
262288
263289 period := int64 (d .Get ("period" ).(int ))
264- log .Printf (fmt .Sprintf ("%dm" , period ))
265290 request .Period = helper .String (fmt .Sprintf ("%dm" , period ))
266291 // only support create profession instance
267292 request .InstanceType = helper .Int64 (1 )
@@ -320,6 +345,14 @@ func resourceTencentCloudCkafkaInstanceCreate(d *schema.ResourceData, meta inter
320345 request .DiskType = helper .String (diskType )
321346 }
322347
348+ if flag := d .Get ("multi_zone_flag" ).(bool ); flag {
349+ request .MultiZoneFlag = helper .Bool (flag )
350+ ids := d .Get ("zone_ids" ).(* schema.Set ).List ()
351+ for _ , v := range ids {
352+ request .ZoneIds = append (request .ZoneIds , helper .IntInt64 (v .(int )))
353+ }
354+ }
355+
323356 result , err := service .client .UseCkafkaClient ().CreateInstancePre (request )
324357 response = result
325358
@@ -462,6 +495,16 @@ func resourceTencentCloudCkafkaInstanceRead(d *schema.ResourceData, meta interfa
462495 _ = d .Set ("disk_size" , info .DiskSize )
463496 _ = d .Set ("band_width" , info .Bandwidth )
464497 _ = d .Set ("partition" , info .MaxPartitionNumber )
498+
499+ if len (info .ZoneIds ) > 0 {
500+ _ = d .Set ("multi_zone_flag" , true )
501+ ids := helper .Int64sInterfaces (info .ZoneIds )
502+ idSet := schema .NewSet (func (i interface {}) int {
503+ return i .(int )
504+ }, ids )
505+ _ = d .Set ("zone_ids" , idSet )
506+ }
507+
465508 tagSets := make ([]map [string ]interface {}, 0 , len (info .Tags ))
466509 for _ , item := range info .Tags {
467510 tagSets = append (tagSets , map [string ]interface {}{
@@ -610,7 +653,13 @@ func resourceTencentCLoudCkafkaInstanceDelete(d *schema.ResourceData, meta inter
610653 )
611654 instanceId := d .Id ()
612655 request .InstanceId = & instanceId
613- _ , err := service .client .UseCkafkaClient ().DeleteInstancePre (request )
656+ err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
657+ _ , err := service .client .UseCkafkaClient ().DeleteInstancePre (request )
658+ if err != nil {
659+ retryError (err , "UnsupportedOperation" )
660+ }
661+ return nil
662+ })
614663 if err != nil {
615664 return err
616665 }
0 commit comments