public async Task <bool> MessageExistsInRecentLogEventsAsync(string message, string logGroupName, string logGroupNamePrefix) { var attemptCount = 0; const int maxAttempts = 5; while (attemptCount < maxAttempts) { attemptCount += 1; var recentLogEvents = await GetRecentLogEventsAsync(logGroupName, logGroupNamePrefix); if (recentLogEvents.Any(x => x.Message.Contains(message))) { return(true); } await Task.Delay(StaticHelpers.GetWaitTime(attemptCount)); } return(false); }