@@ -160,6 +160,32 @@ func ResourceTencentCloudSqlserverGeneralCloudInstance() *schema.Resource {
160
160
Computed : true ,
161
161
Description : "External port number." ,
162
162
},
163
+ "multi_zones" : {
164
+ Type : schema .TypeBool ,
165
+ Optional : true ,
166
+ Computed : true ,
167
+ Description : "Whether to deploy across availability zones, the default value is false." ,
168
+ },
169
+ "multi_nodes" : {
170
+ Type : schema .TypeBool ,
171
+ Optional : true ,
172
+ Computed : true ,
173
+ Description : "Whether it is a multi-node architecture instance, the default value is false. When MultiNodes = true, the parameter MultiZones must be true." ,
174
+ },
175
+ "dr_zones" : {
176
+ Type : schema .TypeSet ,
177
+ Optional : true ,
178
+ Computed : true ,
179
+ Description : "The standby node availability area is empty by default. When MultiNodes = true, the primary node and standby node availability areas cannot all be the same. The minimum number of standby availability areas set is 2, and the maximum number is no more than 5." ,
180
+ Elem : & schema.Schema {
181
+ Type : schema .TypeString ,
182
+ },
183
+ },
184
+ "disk_encrypt_flag" : {
185
+ Type : schema .TypeInt ,
186
+ Optional : true ,
187
+ Description : "Disk encryption identification, 0-not encrypted, 1-encrypted." ,
188
+ },
163
189
},
164
190
}
165
191
}
@@ -279,6 +305,23 @@ func resourceTencentCloudSqlserverGeneralCloudInstanceCreate(d *schema.ResourceD
279
305
request .TimeZone = helper .String (v .(string ))
280
306
}
281
307
308
+ if v , ok := d .GetOkExists ("multi_zones" ); ok {
309
+ request .MultiZones = helper .Bool (v .(bool ))
310
+ }
311
+ if v , ok := d .GetOkExists ("multi_nodes" ); ok {
312
+ request .MultiNodes = helper .Bool (v .(bool ))
313
+ }
314
+ if v , ok := d .GetOk ("dr_zones" ); ok {
315
+ drZones := v .(* schema.Set ).List ()
316
+ for i := range drZones {
317
+ drZone := drZones [i ].(string )
318
+ request .DrZones = append (request .DrZones , & drZone )
319
+ }
320
+ }
321
+ if v , ok := d .GetOkExists ("disk_encrypt_flag" ); ok {
322
+ request .DiskEncryptFlag = helper .IntInt64 (v .(int ))
323
+ }
324
+
282
325
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
283
326
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseSqlserverClient ().CreateCloudDBInstances (request )
284
327
if e != nil {
@@ -430,6 +473,44 @@ func resourceTencentCloudSqlserverGeneralCloudInstanceRead(d *schema.ResourceDat
430
473
_ = d .Set ("tgw_wan_vport" , generalCloudInstance .TgwWanVPort )
431
474
}
432
475
476
+ if generalCloudInstance .IsDrZone != nil {
477
+ _ = d .Set ("multi_zones" , generalCloudInstance .IsDrZone )
478
+ }
479
+
480
+ if len (generalCloudInstance .MultiSlaveZones ) > 0 {
481
+ _ = d .Set ("multi_nodes" , true )
482
+ drZones := make ([]string , 0 )
483
+ for _ , multiSlaveZone := range generalCloudInstance .MultiSlaveZones {
484
+ drZones = append (drZones , * multiSlaveZone .SlaveZone )
485
+ }
486
+ if len (drZones ) > 0 {
487
+ _ = d .Set ("dr_zones" , drZones )
488
+ }
489
+ } else {
490
+ _ = d .Set ("multi_nodes" , false )
491
+ }
492
+
493
+ var insAttribute * sqlserver.DescribeDBInstancesAttributeResponseParams
494
+ paramMap := map [string ]interface {}{
495
+ "InstanceId" : helper .String (instanceId ),
496
+ }
497
+ err = resource .Retry (tccommon .ReadRetryTimeout , func () * resource.RetryError {
498
+ result , e := service .DescribeSqlserverInsAttributeByFilter (ctx , paramMap )
499
+ if e != nil {
500
+ return tccommon .RetryError (e )
501
+ }
502
+
503
+ insAttribute = result
504
+ return nil
505
+ })
506
+
507
+ if err != nil {
508
+ return err
509
+ }
510
+
511
+ if insAttribute .IsDiskEncryptFlag != nil {
512
+ _ = d .Set ("disk_encrypt_flag" , insAttribute .IsDiskEncryptFlag )
513
+ }
433
514
maintenanceSpan , err := service .DescribeMaintenanceSpanById (ctx , instanceId )
434
515
if err != nil {
435
516
return err
@@ -488,7 +569,7 @@ func resourceTencentCloudSqlserverGeneralCloudInstanceUpdate(d *schema.ResourceD
488
569
)
489
570
490
571
request .InstanceId = & instanceId
491
- immutableArgs := []string {"zone" , "machine_type" , "instance_charge_type" , "project_id" , "subnet_id" , "vpc_id" , "period" , "security_group_list" , "weekly" , "start_time" , "span" , "resource_tags" , "collation" , "time_zone" }
572
+ immutableArgs := []string {"zone" , "machine_type" , "instance_charge_type" , "project_id" , "subnet_id" , "vpc_id" , "period" , "security_group_list" , "weekly" , "start_time" , "span" , "resource_tags" , "collation" , "time_zone" , "multi_zones" , "multi_nodes" , "dr_zones" , "disk_encrypt_flag" }
492
573
493
574
for _ , v := range immutableArgs {
494
575
if d .HasChange (v ) {
0 commit comments