private async Task <string> GetLatestLogStreamNameAsync(string logGroupName, string logGroupNamePrefix) { var attemptCount = 0; const int maxAttempts = 5; while (attemptCount < maxAttempts) { attemptCount += 1; if (await LogGroupExistsAsync(logGroupName, logGroupNamePrefix)) { break; } await Task.Delay(StaticHelpers.GetWaitTime(attemptCount)); } var response = await _cloudWatchlogsClient.DescribeLogStreamsAsync( new DescribeLogStreamsRequest { LogGroupName = logGroupName, Descending = true, Limit = 1 }); return(response.LogStreams.FirstOrDefault()?.LogStreamName); }
public async Task <bool> IsDeletedAsync(string stackName) { var attemptCount = 0; const int maxAttempts = 5; while (attemptCount < maxAttempts) { attemptCount += 1; if (!await StackExistsAsync(stackName)) { return(true); } await Task.Delay(StaticHelpers.GetWaitTime(attemptCount)); } return(false); }
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); }