private async Task UpsertSubscriptionFilter(PutSubscriptionFilterRequest request) { Console.WriteLine("Upserting Subscription Filter..."); var subscriptionFilters = await _cloudWatchLogs.DescribeSubscriptionFiltersAsync(new DescribeSubscriptionFiltersRequest { LogGroupName = request.LogGroupName }); var subscriptionFilter = subscriptionFilters.SubscriptionFilters.First(); if (subscriptionFilter.FilterName != request.FilterName || subscriptionFilter.FilterPattern != request.FilterPattern) { await Task.WhenAll(_cloudWatchLogs.DeleteSubscriptionFilterAsync(new DeleteSubscriptionFilterRequest { FilterName = subscriptionFilter.FilterName, LogGroupName = request.LogGroupName }), _cloudWatchLogs.PutSubscriptionFilterAsync(request)); } }