-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathresource_tc_sqlserver_general_cloud_instance.go
640 lines (545 loc) · 20.2 KB
/
resource_tc_sqlserver_general_cloud_instance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
package sqlserver
import (
"context"
"fmt"
"log"
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
sqlserver "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sqlserver/v20180328"
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
)
func ResourceTencentCloudSqlserverGeneralCloudInstance() *schema.Resource {
return &schema.Resource{
Create: resourceTencentCloudSqlserverGeneralCloudInstanceCreate,
Read: resourceTencentCloudSqlserverGeneralCloudInstanceRead,
Update: resourceTencentCloudSqlserverGeneralCloudInstanceUpdate,
Delete: resourceTencentCloudSqlserverGeneralCloudInstanceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: tccommon.ValidateStringLengthInRange(1, 60),
Description: "Name of the SQL Server instance.",
},
"zone": {
Required: true,
Type: schema.TypeString,
Description: "Instance AZ, such as ap-guangzhou-1 (Guangzhou Zone 1). Purchasable AZs for an instance can be obtained through the DescribeZones API.",
},
"memory": {
Required: true,
Type: schema.TypeInt,
Description: "Memory, unit: GB.",
},
"storage": {
Required: true,
Type: schema.TypeInt,
Description: "instance disk storage, unit: GB.",
},
"cpu": {
Required: true,
Type: schema.TypeInt,
Description: "Cpu, unit: CORE.",
},
"machine_type": {
Required: true,
Type: schema.TypeString,
Description: "The host disk type of the purchased instance, CLOUD_HSSD-enhanced SSD cloud disk for virtual machines, CLOUD_TSSD-extremely fast SSD cloud disk for virtual machines, CLOUD_BSSD-universal SSD cloud disk for virtual machines.",
},
"instance_charge_type": {
Optional: true,
Type: schema.TypeString,
Description: "Payment mode, the value supports PREPAID (prepaid), POSTPAID (postpaid).",
},
"project_id": {
Optional: true,
Type: schema.TypeInt,
Description: "project ID.",
},
"subnet_id": {
Optional: true,
Type: schema.TypeString,
Description: "VPC subnet ID, in the form of subnet-bdoe83fa; SubnetId and VpcId need to be set at the same time or not set at the same time.",
},
"vpc_id": {
Optional: true,
Type: schema.TypeString,
Description: "VPC network ID, in the form of vpc-dsp338hz; SubnetId and VpcId need to be set at the same time or not set at the same time.",
},
"period": {
Optional: true,
Type: schema.TypeInt,
ValidateFunc: tccommon.ValidateIntegerInRange(1, 48),
Description: "Purchase instance period, the default value is 1, which means one month. The value cannot exceed 48. Valid only when the 'instance_charge_type' parameter value is 'PREPAID'.",
},
"db_version": {
Optional: true,
Type: schema.TypeString,
Description: "sqlserver version, currently all supported versions are: 2008R2 (SQL Server 2008 R2 Enterprise), 2012SP3 (SQL Server 2012 Enterprise), 201202 (SQL Server 2012 Standard), 2014SP2 (SQL Server 2014 Enterprise), 201402 (SQL Server 2014 Standard), 2016SP1 (SQL Server 2016 Enterprise), 201602 (SQL Server 2016 Standard), 2017 (SQL Server 2017 Enterprise), 201702 (SQL Server 2017 Standard), 2019 (SQL Server 2019 Enterprise), 201902 (SQL Server 2019 Standard). Each region supports different versions for sale, and the version information that can be sold in each region can be pulled through the DescribeProductConfig interface. If left blank, the default version is 2008R2.",
},
"auto_renew_flag": {
Optional: true,
Type: schema.TypeInt,
Description: "Automatic renewal flag: 0-normal renewal 1-automatic renewal, the default is 1 automatic renewal. Valid only when purchasing a prepaid instance. Valid only when the 'instance_charge_type' parameter value is 'PREPAID'.",
},
"security_group_list": {
Optional: true,
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Description: "Security group list, fill in the security group ID in the form of sg-xxx.",
},
"weekly": {
Optional: true,
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeInt},
Description: "Maintainable time window configuration, in weeks, indicates the days of the week that allow maintenance, 1-7 represent Monday to weekend respectively.",
},
"start_time": {
Optional: true,
Type: schema.TypeString,
Description: "Maintainable time window configuration, daily maintainable start time.",
},
"span": {
Optional: true,
Type: schema.TypeInt,
Description: "Maintainable time window configuration, duration, unit: hour.",
},
"resource_tags": {
Optional: true,
Type: schema.TypeList,
Description: "A collection of tags bound to the new instance.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"tag_key": {
Type: schema.TypeString,
Optional: true,
Description: "tag key.",
},
"tag_value": {
Type: schema.TypeString,
Optional: true,
Description: "tag value.",
},
},
},
},
"collation": {
Optional: true,
Type: schema.TypeString,
Default: "Chinese_PRC_CI_AS",
Description: "System character set collation, default: Chinese_PRC_CI_AS.",
},
"time_zone": {
Optional: true,
Type: schema.TypeString,
Default: "China Standard Time",
Description: "System time zone, default: China Standard Time.",
},
"ha_type": {
Optional: true,
Type: schema.TypeString,
Deprecated: "It has been deprecated from version 1.81.2.",
Description: "Upgrade the high-availability architecture of sqlserver, upgrade from mirror disaster recovery to always on cluster disaster recovery, only support 2017 and above and support always on high-availability instances, do not support downgrading to mirror disaster recovery, CLUSTER-upgrade to always on capacity Disaster, if not filled, the high-availability architecture will not be modified.",
},
"dns_pod_domain": {
Type: schema.TypeString,
Computed: true,
Description: "Internet address domain name.",
},
"tgw_wan_vport": {
Type: schema.TypeInt,
Computed: true,
Description: "External port number.",
},
"auto_voucher": {
Type: schema.TypeInt,
Optional: true,
Description: "Whether to automatically use vouchers;1-Yes, 0-No, not used by default.",
},
"voucher_ids": {
Type: schema.TypeInt,
Optional: true,
Description: "Voucher ID array. Currently, only one can be used for a single order.",
},
"multi_zones": {
Type: schema.TypeInt,
Optional: true,
Description: "Whether to deploy across availability zones, the default value is false.",
},
"multi_nodes": {
Type: schema.TypeInt,
Optional: true,
Description: "Whether it is a multi-node architecture instance, the default value is false. When MultiNodes = true, the parameter MultiZones must be true.",
},
"dr_zones": {
Type: schema.TypeInt,
Optional: true,
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.",
},
"disk_encrypt_flag": {
Type: schema.TypeInt,
Optional: true,
Description: "Disk encryption identification, 0-not encrypted, 1-encrypted.",
},
},
}
}
func resourceTencentCloudSqlserverGeneralCloudInstanceCreate(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_sqlserver_general_cloud_instance.create")()
defer tccommon.InconsistentCheck(d, meta)()
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
service = SqlserverService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
request = sqlserver.NewCreateCloudDBInstancesRequest()
instanceId string
instanceName string
dealId string
)
if v, ok := d.GetOk("name"); ok {
instanceName = v.(string)
}
if v, ok := d.GetOk("zone"); ok {
request.Zone = helper.String(v.(string))
}
if v, ok := d.GetOk("memory"); ok {
request.Memory = helper.IntInt64(v.(int))
}
if v, ok := d.GetOk("storage"); ok {
request.Storage = helper.IntInt64(v.(int))
}
if v, ok := d.GetOk("cpu"); ok {
request.Cpu = helper.IntUint64(v.(int))
}
if v, ok := d.GetOk("machine_type"); ok {
request.MachineType = helper.String(v.(string))
}
if v, ok := d.GetOk("instance_charge_type"); ok {
request.InstanceChargeType = helper.String(v.(string))
if v.(string) == SQLSERVER_TYPE_PREPAID {
if v, ok := d.GetOk("period"); ok {
request.Period = helper.IntInt64(v.(int))
}
if v, ok := d.GetOk("auto_renew_flag"); ok {
request.AutoRenewFlag = helper.IntInt64(v.(int))
}
}
}
if v, ok := d.GetOk("project_id"); ok {
request.ProjectId = helper.IntInt64(v.(int))
}
if v, ok := d.GetOk("subnet_id"); ok {
request.SubnetId = helper.String(v.(string))
}
if v, ok := d.GetOk("vpc_id"); ok {
request.VpcId = helper.String(v.(string))
}
if v, ok := d.GetOk("db_version"); ok {
request.DBVersion = helper.String(v.(string))
}
if v, ok := d.GetOk("security_group_list"); ok {
securityGroupListSet := v.(*schema.Set).List()
for i := range securityGroupListSet {
securityGroupList := securityGroupListSet[i].(string)
request.SecurityGroupList = append(request.SecurityGroupList, &securityGroupList)
}
}
if v, ok := d.GetOk("weekly"); ok {
weeklySet := v.(*schema.Set).List()
for i := range weeklySet {
weekly := weeklySet[i].(int)
request.Weekly = append(request.Weekly, helper.IntInt64(weekly))
}
}
if v, ok := d.GetOk("start_time"); ok {
request.StartTime = helper.String(v.(string))
}
if v, ok := d.GetOk("span"); ok {
request.Span = helper.IntInt64(v.(int))
}
request.MultiZones = helper.Bool(true)
if v, ok := d.GetOk("resource_tags"); ok {
for _, item := range v.([]interface{}) {
dMap := item.(map[string]interface{})
resourceTag := sqlserver.ResourceTag{}
if v, ok := dMap["tag_key"]; ok {
resourceTag.TagKey = helper.String(v.(string))
}
if v, ok := dMap["tag_value"]; ok {
resourceTag.TagValue = helper.String(v.(string))
}
request.ResourceTags = append(request.ResourceTags, &resourceTag)
}
}
if v, ok := d.GetOk("collation"); ok {
request.Collation = helper.String(v.(string))
}
if v, ok := d.GetOk("time_zone"); ok {
request.TimeZone = helper.String(v.(string))
}
if v, ok := d.GetOk("auto_voucher"); ok {
request.AutoVoucher = helper.IntInt64(v.(int))
}
if v, ok := d.GetOk("voucher_ids"); ok {
request.VoucherIds = helper.InterfacesStringsPoint(v.([]interface{}))
}
if v, ok := d.GetOkExists("multi_zones"); ok {
request.MultiZones = helper.Bool(v.(bool))
}
if v, ok := d.GetOkExists("multi_nodes"); ok {
request.MultiZones = helper.Bool(v.(bool))
}
if v, ok := d.GetOk("dr_zones"); ok {
request.DrZones = helper.InterfacesStringsPoint(v.([]interface{}))
}
if v, ok := d.GetOkExists("disk_encrypt_flag"); ok {
request.DiskEncryptFlag = helper.IntInt64(v.(int))
}
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseSqlserverClient().CreateCloudDBInstances(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}
dealId = *result.Response.DealName
return nil
})
if err != nil {
log.Printf("[CRITAL]%s create sqlserver generalCloudInstance failed, reason:%+v", logId, err)
return err
}
instanceId, err = service.GetInfoFromDeal(ctx, dealId)
if err != nil {
return err
}
// set name
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
inErr := service.ModifySqlserverInstanceName(ctx, instanceId, instanceName)
if inErr != nil {
return tccommon.RetryError(inErr)
}
return nil
})
if err != nil {
return err
}
d.SetId(instanceId)
return resourceTencentCloudSqlserverGeneralCloudInstanceRead(d, meta)
}
func resourceTencentCloudSqlserverGeneralCloudInstanceRead(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_sqlserver_general_cloud_instance.read")()
defer tccommon.InconsistentCheck(d, meta)()
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
service = SqlserverService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
instanceId = d.Id()
)
generalCloudInstance, err := service.DescribeSqlserverGeneralCloudInstanceById(ctx, instanceId)
if err != nil {
return err
}
if generalCloudInstance == nil {
d.SetId("")
log.Printf("[WARN]%s resource `SqlserverGeneralCloudInstance` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}
if generalCloudInstance.Name != nil {
_ = d.Set("name", generalCloudInstance.Name)
}
if generalCloudInstance.Zone != nil {
_ = d.Set("zone", generalCloudInstance.Zone)
}
if generalCloudInstance.Memory != nil {
_ = d.Set("memory", generalCloudInstance.Memory)
}
if generalCloudInstance.Storage != nil {
_ = d.Set("storage", generalCloudInstance.Storage)
}
if generalCloudInstance.Cpu != nil {
_ = d.Set("cpu", generalCloudInstance.Cpu)
}
if generalCloudInstance.Type != nil {
_ = d.Set("machine_type", generalCloudInstance.Type)
}
if generalCloudInstance.PayMode != nil {
if *generalCloudInstance.PayMode == 0 {
_ = d.Set("instance_charge_type", SQLSERVER_TYPE_POSTPAID)
} else {
_ = d.Set("instance_charge_type", SQLSERVER_TYPE_PREPAID)
}
}
if generalCloudInstance.ProjectId != nil {
_ = d.Set("project_id", generalCloudInstance.ProjectId)
}
if generalCloudInstance.UniqSubnetId != nil {
_ = d.Set("subnet_id", generalCloudInstance.UniqSubnetId)
}
if generalCloudInstance.UniqVpcId != nil {
_ = d.Set("vpc_id", generalCloudInstance.UniqVpcId)
}
if generalCloudInstance.Version != nil {
_ = d.Set("db_version", generalCloudInstance.Version)
}
if generalCloudInstance.RenewFlag != nil {
_ = d.Set("auto_renew_flag", generalCloudInstance.RenewFlag)
}
if generalCloudInstance.ResourceTags != nil {
resourceTagsList := []interface{}{}
for _, resourceTags := range generalCloudInstance.ResourceTags {
resourceTagsMap := map[string]interface{}{}
if resourceTags.TagKey != nil {
resourceTagsMap["tag_key"] = resourceTags.TagKey
}
if resourceTags.TagValue != nil {
resourceTagsMap["tag_value"] = resourceTags.TagValue
}
resourceTagsList = append(resourceTagsList, resourceTagsMap)
}
_ = d.Set("resource_tags", resourceTagsList)
}
if generalCloudInstance.Collation != nil {
_ = d.Set("collation", generalCloudInstance.Collation)
}
if generalCloudInstance.TimeZone != nil {
_ = d.Set("time_zone", generalCloudInstance.TimeZone)
}
if generalCloudInstance.DnsPodDomain != nil {
_ = d.Set("dns_pod_domain", generalCloudInstance.DnsPodDomain)
}
if generalCloudInstance.TgwWanVPort != nil {
_ = d.Set("tgw_wan_vport", generalCloudInstance.TgwWanVPort)
}
maintenanceSpan, err := service.DescribeMaintenanceSpanById(ctx, instanceId)
if err != nil {
return err
}
if maintenanceSpan == nil {
d.SetId("")
log.Printf("[WARN]%s resource `SqlservereMaintenanceSpan` [%s] not found, please check if it has been deleted.", logId, d.Id())
return nil
}
if maintenanceSpan.Span != nil {
_ = d.Set("span", maintenanceSpan.Span)
}
if maintenanceSpan.StartTime != nil {
_ = d.Set("start_time", maintenanceSpan.StartTime)
}
if maintenanceSpan.Weekly != nil {
_ = d.Set("weekly", maintenanceSpan.Weekly)
}
securityGroupList, err := service.DescribeInstanceSecurityGroups(ctx, instanceId)
if err != nil {
return err
}
if securityGroupList == nil {
d.SetId("")
log.Printf("[WARN]%s resource `SqlservereSecurityGroups` [%s] not found, please check if it has been deleted.", logId, d.Id())
return nil
}
if securityGroupList != nil {
_ = d.Set("security_group_list", securityGroupList)
}
return nil
}
func resourceTencentCloudSqlserverGeneralCloudInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_sqlserver_general_cloud_instance.update")()
defer tccommon.InconsistentCheck(d, meta)()
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
client = meta.(tccommon.ProviderMeta).GetAPIV3Conn()
sqlserverService = SqlserverService{client: client}
request = sqlserver.NewUpgradeDBInstanceRequest()
instanceId = d.Id()
waitSwitch int64
dealId string
instanceName string
)
request.InstanceId = &instanceId
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", "auto_voucher", "voucher_ids", "multi_zones", "multi_nodes", "dr_zones", "disk_encrypt_flag"}
for _, v := range immutableArgs {
if d.HasChange(v) {
return fmt.Errorf("argument `%s` cannot be changed", v)
}
}
if d.HasChange("name") {
if v, ok := d.GetOk("name"); ok {
instanceName = v.(string)
// set name
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
inErr := sqlserverService.ModifySqlserverInstanceName(ctx, instanceId, instanceName)
if inErr != nil {
return tccommon.RetryError(inErr)
}
return nil
})
if err != nil {
return err
}
}
}
if d.HasChange("memory") {
if v, ok := d.GetOk("memory"); ok {
request.Memory = helper.IntInt64(v.(int))
}
}
if d.HasChange("storage") {
if v, ok := d.GetOk("storage"); ok {
request.Storage = helper.IntInt64(v.(int))
}
}
if d.HasChange("cpu") {
if v, ok := d.GetOk("cpu"); ok {
request.Cpu = helper.IntInt64(v.(int))
}
}
if d.HasChange("db_version") {
if v, ok := d.GetOk("db_version"); ok {
request.DBVersion = helper.String(v.(string))
}
}
waitSwitch = 0
request.WaitSwitch = &waitSwitch
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseSqlserverClient().UpgradeDBInstance(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}
dealId = *result.Response.DealName
return nil
})
if err != nil {
log.Printf("[CRITAL]%s update sqlserver generalCloudInstance failed, reason:%+v", logId, err)
return err
}
_, err = sqlserverService.GetInfoFromDeal(ctx, dealId)
if err != nil {
return err
}
return resourceTencentCloudSqlserverGeneralCloudInstanceRead(d, meta)
}
func resourceTencentCloudSqlserverGeneralCloudInstanceDelete(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_sqlserver_general_cloud_instance.delete")()
defer tccommon.InconsistentCheck(d, meta)()
var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
service = SqlserverService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
instanceId = d.Id()
)
if err := service.TerminateSqlserverInstanceById(ctx, instanceId); err != nil {
return err
}
if err := service.DeleteSqlserverInstanceById(ctx, instanceId); err != nil {
return err
}
return nil
}