diff --git a/pkg/aws/errors/errors.go b/pkg/aws/errors/errors.go index c665eda..7349b57 100644 --- a/pkg/aws/errors/errors.go +++ b/pkg/aws/errors/errors.go @@ -75,3 +75,8 @@ func IsInvalidTokenException(err error) bool { return IsErrorCode(err, InvalidClientTokenID) } +func IsDeleteConfictException(err error) bool { + var deleteConflict *iamtypes.DeleteConflictException + return errors.As(err, &deleteConflict) +} + diff --git a/pkg/aws/errors/errors_test.go b/pkg/aws/errors/errors_test.go index 0ddc080..4fbcdf3 100644 --- a/pkg/aws/errors/errors_test.go +++ b/pkg/aws/errors/errors_test.go @@ -65,4 +65,10 @@ var _ = Describe("Error Checks", func() { Expect(IsErrorCode(err, "DifferentCode")).To(BeFalse()) }) + It("should identify IsDeleteConfictException", func() { + err := &iamtypes.DeleteConflictException{} + Expect(IsDeleteConfictException(err)).To(BeTrue()) + Expect(IsDeleteConfictException(errors.New("random error"))).To(BeFalse()) + }) + })