diff --git a/.changelog/2502.txt b/.changelog/2502.txt new file mode 100644 index 0000000000..9c183c977a --- /dev/null +++ b/.changelog/2502.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_mysql_instance: Optimize the availability zone problem when modifying the configuration after active/standby switchover. +``` diff --git a/tencentcloud/services/cdb/resource_tc_mysql_instance.go b/tencentcloud/services/cdb/resource_tc_mysql_instance.go index fa26613718..9da7393edf 100644 --- a/tencentcloud/services/cdb/resource_tc_mysql_instance.go +++ b/tencentcloud/services/cdb/resource_tc_mysql_instance.go @@ -1068,7 +1068,7 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met memSize := int64(d.Get("mem_size").(int)) cpu := int64(d.Get("cpu").(int)) volumeSize := int64(d.Get("volume_size").(int)) - slaveDeployMode := int64(d.Get("slave_deploy_mode").(int)) + var slaveDeployMode int64 = -1 slaveSyncMode := int64(d.Get("slave_sync_mode").(int)) deviceType := "" firstSlaveZone := "" @@ -1095,6 +1095,12 @@ func mysqlAllInstanceRoleUpdate(ctx context.Context, d *schema.ResourceData, met waitSwitch = int64(v.(int)) } + if d.HasChange("slave_deploy_mode") { + if v, ok := d.GetOkExists("slave_deploy_mode"); ok { + slaveDeployMode = int64(v.(int)) + } + } + asyncRequestId, err := mysqlService.UpgradeDBInstance(ctx, d.Id(), memSize, cpu, volumeSize, fastUpgrade, deviceType, slaveDeployMode, slaveSyncMode, firstSlaveZone, secondSlaveZone, waitSwitch) if err != nil {