@@ -169,19 +169,24 @@ func resourceTencentCloudIdentityCenterRoleAssignmentCreate(d *schema.ResourceDa
169
169
}
170
170
if task .Status != nil && * task .Status == TASK_STATUS_FAILED {
171
171
if task .FailureReason != nil {
172
- return fmt .Errorf ("CreateRoleAssignment failed, failure reason:%s" , * task .FailureReason )
172
+ return fmt .Errorf ("create role assignment task failed, failure reason:%s" , * task .FailureReason )
173
173
}
174
- return fmt .Errorf ("CreateRoleAssignment failed" )
174
+ return fmt .Errorf ("create role assignment task failed" )
175
175
}
176
176
177
177
if task .TaskId == nil {
178
- return fmt .Errorf ("task id is nil" )
178
+ return fmt .Errorf ("create role assignment task id is nil" )
179
179
}
180
180
taskId := * task .TaskId
181
181
roleConfigurationId := * task .RoleConfigurationId
182
182
conf := tccommon .BuildStateChangeConf ([]string {}, []string {TASK_STATUS_SUCCESS , TASK_STATUS_FAILED }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , taskId , []string {}))
183
- if _ , e := conf .WaitForState (); e != nil {
183
+ if object , e := conf .WaitForState (); e != nil {
184
184
return e
185
+ } else {
186
+ taskStatus := object .(* organization.TaskStatus )
187
+ if taskStatus .Status != nil && * taskStatus .Status == TASK_STATUS_FAILED {
188
+ return fmt .Errorf ("create role assignment task failed" )
189
+ }
185
190
}
186
191
187
192
targetUinString := strconv .FormatInt (targetUin , 10 )
@@ -322,14 +327,20 @@ func resourceTencentCloudIdentityCenterRoleAssignmentDelete(d *schema.ResourceDa
322
327
task := deleteRoleAssignmentResponse .Response .Task
323
328
if task .Status != nil && * task .Status == TASK_STATUS_FAILED {
324
329
if task .FailureReason != nil {
325
- return fmt .Errorf ("DeleteRoleAssignment failed, failure reason:%s" , * task .FailureReason )
330
+ return fmt .Errorf ("delete role assignment failed, failure reason:%s" , * task .FailureReason )
326
331
}
327
- return fmt .Errorf ("DeleteRoleAssignment failed" )
332
+ return fmt .Errorf ("delete role assignment failed" )
328
333
}
329
- if task .TaskId != nil {
330
- conf := tccommon .BuildStateChangeConf ([]string {}, []string {"Success" }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , * task .TaskId , []string {}))
331
- if _ , e := conf .WaitForState (); e != nil {
332
- return e
334
+ if task .TaskId == nil {
335
+ return fmt .Errorf ("delete role assignment task id is nil" )
336
+ }
337
+ conf := tccommon .BuildStateChangeConf ([]string {}, []string {TASK_STATUS_SUCCESS , TASK_STATUS_FAILED }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , * task .TaskId , []string {}))
338
+ if object , e := conf .WaitForState (); e != nil {
339
+ return e
340
+ } else {
341
+ taskStatus := object .(* organization.TaskStatus )
342
+ if taskStatus .Status != nil && * taskStatus .Status == TASK_STATUS_FAILED {
343
+ return fmt .Errorf ("delete role assignment failed" )
333
344
}
334
345
}
335
346
@@ -352,10 +363,28 @@ func resourceTencentCloudIdentityCenterRoleAssignmentDelete(d *schema.ResourceDa
352
363
return err
353
364
}
354
365
355
- if dismantleRoleConfigurationResponse .Response != nil && dismantleRoleConfigurationResponse .Response .Task != nil && dismantleRoleConfigurationResponse .Response .Task .TaskId != nil {
356
- conf := tccommon .BuildStateChangeConf ([]string {}, []string {TASK_STATUS_SUCCESS , TASK_STATUS_FAILED }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , * dismantleRoleConfigurationResponse .Response .Task .TaskId , []string {}))
357
- if _ , e := conf .WaitForState (); e != nil {
358
- return e
366
+ if dismantleRoleConfigurationResponse == nil || dismantleRoleConfigurationResponse .Response == nil {
367
+ return fmt .Errorf ("dismantle role assignment response is nil" )
368
+ }
369
+ if dismantleRoleConfigurationResponse .Response .Task == nil {
370
+ return fmt .Errorf ("dismantle role assignment task is nil" )
371
+ }
372
+ dismantleTask := dismantleRoleConfigurationResponse .Response .Task
373
+
374
+ if dismantleTask .TaskStatus != nil && * dismantleTask .TaskStatus == TASK_STATUS_FAILED {
375
+ return fmt .Errorf ("dismantle role assignment task failed" )
376
+ }
377
+
378
+ if dismantleTask .TaskId == nil {
379
+ return fmt .Errorf ("dismantle role assignment task id is nil" )
380
+ }
381
+ conf = tccommon .BuildStateChangeConf ([]string {}, []string {TASK_STATUS_SUCCESS , TASK_STATUS_FAILED }, 2 * tccommon .ReadRetryTimeout , time .Second , service .AssignmentTaskStatusStateRefreshFunc (zoneId , * dismantleTask .TaskId , []string {}))
382
+ if object , e := conf .WaitForState (); e != nil {
383
+ return e
384
+ } else {
385
+ taskStatus := object .(* organization.TaskStatus )
386
+ if taskStatus .Status != nil && * taskStatus .Status == TASK_STATUS_FAILED {
387
+ return fmt .Errorf ("dismantle role assignment task failed" )
359
388
}
360
389
}
361
390
0 commit comments