Securityhub "The request is rejected since no such resource found." exception using sdk

81 Views Asked by At

getting the following exception while cleaning up securityhub using aws sdk

The request is rejected since no such resource found., in region Asia Pacific (Singapore) (ap-southeast-1)

i hv tried cleaning up security hub in multiple regions and have used try and catch blocks as follows but then also for one specific regions it is gng inside else block even though the exception message is "The request is rejected since no such resource found."so want to know the root cause of why do we get these exception

          try
            {
             var securityHubIssue = 'The request is rejected since no such resource found.'
                //delete code
             
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains(securityHubIssue))
                {
                    var logDescription = string.Format("Cleanup excluded in aws account {0} due to the reason with exception: {1},in region {2}", subscription.Guid, ex.Message, region);
                    
                }
                else
                {
                    var logDescription = string.Format("Cleanup failed in AWS account {0}, Failed to delete Invitations in SecurityHub with exception: {1},in region {2}", subscription.Guid, ex.Message, region);
                }
            }
0

There are 0 best solutions below