private async Task <Stack?> GetStackAsync(string stackName)
        {
            var retryCount  = 0;
            var shouldRetry = false;

            Stack?stack = null;

            do
            {
                var waitTime = GetWaitTime(retryCount);
                try
                {
                    await Task.Delay(waitTime);

                    var response = await _cloudFormationClient.DescribeStacksAsync(new DescribeStacksRequest
                    {
                        StackName = stackName
                    });

                    stack       = response.Stacks.Count == 0 ? null : response.Stacks[0];
                    shouldRetry = false;
                }
                catch (AmazonCloudFormationException exception) when(exception.ErrorCode.Equals("ValidationError") && exception.Message.Equals($"Stack with id {stackName} does not exist"))
                {
                    shouldRetry = false;
                }
                catch (AmazonCloudFormationException exception) when(exception.ErrorCode.Equals("Throttling"))
                {
                    _interactiveService.WriteDebugLine(exception.PrettyPrint());
                    shouldRetry = true;
                }
            } while (shouldRetry && retryCount++ < MAX_RETRIES);

            return(stack);
        }
Exemple #2
0
 public void LogDebugLine(string?message)
 {
     _interactiveService.WriteDebugLine(message);
 }