Method: Jets::AwsServices::StackStatus#stack_in_progress?

Defined in:
lib/jets/aws_services/stack_status.rb

#stack_in_progress?(stack_name) ⇒ Boolean

All CloudFormation states listed here: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html

Returns resp so we can use it to grab data about the stack without calling api again.

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/jets/aws_services/stack_status.rb', line 36

def stack_in_progress?(stack_name)
  return true if !stack_exists?(stack_name)

  # Assumes stack exists
  resp = cfn.describe_stacks(stack_name: stack_name)
  status = resp.stacks[0].stack_status
  if status =~ /_IN_PROGRESS$/
    puts "The '#{stack_name}' stack status is #{status}. " \
         "Please wait until the stack is ready and try again.".color(:red)
    exit 0
  elsif resp.stacks[0].outputs.empty? && status != 'ROLLBACK_COMPLETE'
    # This Happens when the miminal stack fails at the very beginning.
    # There is no s3 bucket at all.  User should delete the stack.
    puts "The minimal stack failed to create. Please delete the stack first and try again. " \
    "You can delete the CloudFormation stack or use the `jets delete` command"
    exit 0
  else
    true
  end
end