@@ -169,19 +169,24 @@ func resourceTencentCloudIdentityCenterRoleAssignmentCreate(d *schema.ResourceDa
169169 }
170170 if task .Status != nil && * task .Status == TASK_STATUS_FAILED {
171171 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 )
173173 }
174- return fmt .Errorf ("CreateRoleAssignment failed" )
174+ return fmt .Errorf ("create role assignment task failed" )
175175 }
176176
177177 if task .TaskId == nil {
178- return fmt .Errorf ("task id is nil" )
178+ return fmt .Errorf ("create role assignment task id is nil" )
179179 }
180180 taskId := * task .TaskId
181181 roleConfigurationId := * task .RoleConfigurationId
182182 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 {
184184 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+ }
185190 }
186191
187192 targetUinString := strconv .FormatInt (targetUin , 10 )
@@ -322,14 +327,20 @@ func resourceTencentCloudIdentityCenterRoleAssignmentDelete(d *schema.ResourceDa
322327 task := deleteRoleAssignmentResponse .Response .Task
323328 if task .Status != nil && * task .Status == TASK_STATUS_FAILED {
324329 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 )
326331 }
327- return fmt .Errorf ("DeleteRoleAssignment failed" )
332+ return fmt .Errorf ("delete role assignment failed" )
328333 }
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" )
333344 }
334345 }
335346
@@ -352,10 +363,28 @@ func resourceTencentCloudIdentityCenterRoleAssignmentDelete(d *schema.ResourceDa
352363 return err
353364 }
354365
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" )
359388 }
360389 }
361390
0 commit comments