@@ -498,7 +498,7 @@ func deleteResourcesInCloudFormation(prov client.ConfigProvider, t *cfn_bootstra
498
498
By (fmt .Sprintf ("deleting the following role: %s" , role .RoleName ))
499
499
repeat := false
500
500
Eventually (func (gomega Gomega ) bool {
501
- _ , err := iamSvc . DeleteRole (& iam. DeleteRoleInput { RoleName : aws . String ( role .RoleName )} )
501
+ err := DeleteRole (prov , role .RoleName )
502
502
if err != nil && ! repeat {
503
503
By (fmt .Sprintf ("failed to delete role '%s'; reason: %+v" , role .RoleName , err ))
504
504
repeat = true
@@ -529,9 +529,11 @@ func deleteResourcesInCloudFormation(prov client.ConfigProvider, t *cfn_bootstra
529
529
By (fmt .Sprintf ("cleanup for policy '%s'" , p .String ()))
530
530
repeat := false
531
531
Eventually (func (gomega Gomega ) bool {
532
- _ , err := iamSvc .DeletePolicy (& iam.DeletePolicyInput {PolicyArn : p .Arn })
532
+ response , err := iamSvc .DeletePolicy (& iam.DeletePolicyInput {
533
+ PolicyArn : p .Arn ,
534
+ })
533
535
if err != nil && ! repeat {
534
- By (fmt .Sprintf ("failed to delete policy '%s'; reason: %+v" , policy .Description , err ))
536
+ By (fmt .Sprintf ("failed to delete policy '%s'; reason: %+v, response: %s " , policy .Description , err , response . String () ))
535
537
repeat = true
536
538
}
537
539
code , ok := awserrors .Code (err )
@@ -559,8 +561,12 @@ func deleteResourcesInCloudFormation(prov client.ConfigProvider, t *cfn_bootstra
559
561
560
562
// TODO: remove once test infra accounts are fixed.
561
563
func deleteMultitenancyRoles (prov client.ConfigProvider ) {
562
- DeleteRole (prov , "multi-tenancy-role" )
563
- DeleteRole (prov , "multi-tenancy-nested-role" )
564
+ if err := DeleteRole (prov , "multi-tenancy-role" ); err != nil {
565
+ By (fmt .Sprintf ("failed to delete role multi-tenancy-role %s" , err ))
566
+ }
567
+ if err := DeleteRole (prov , "multi-tenancy-nested-role" ); err != nil {
568
+ By (fmt .Sprintf ("failed to delete role multi-tenancy-nested-role %s" , err ))
569
+ }
564
570
}
565
571
566
572
// detachAllPoliciesForRole detaches all policies for role.
@@ -589,23 +595,25 @@ func detachAllPoliciesForRole(prov client.ConfigProvider, name string) error {
589
595
}
590
596
591
597
// DeleteRole deletes roles in a best effort manner.
592
- func DeleteRole (prov client.ConfigProvider , name string ) {
598
+ func DeleteRole (prov client.ConfigProvider , name string ) error {
593
599
iamSvc := iam .New (prov )
594
600
595
601
// if role does not exist, return.
596
602
_ , err := iamSvc .GetRole (& iam.GetRoleInput {RoleName : aws .String (name )})
597
603
if err != nil {
598
- return
604
+ return err
599
605
}
600
606
601
607
if err := detachAllPoliciesForRole (prov , name ); err != nil {
602
- return
608
+ return err
603
609
}
604
610
605
611
_ , err = iamSvc .DeleteRole (& iam.DeleteRoleInput {RoleName : aws .String (name )})
606
612
if err != nil {
607
- return
613
+ return err
608
614
}
615
+
616
+ return nil
609
617
}
610
618
611
619
func GetPolicyArn (prov client.ConfigProvider , name string ) string {
0 commit comments