Method: Jets::Cfn::Status#wait

Defined in:
lib/jets/cfn/status.rb

#waitObject

check for /(_COMPLETE|_FAILED)$/ status



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/jets/cfn/status.rb', line 43

def wait
  start_time = Time.now

  refresh_events
  until completed || @stack_deletion_completed
    show_events
  end
  show_events(true) # show the final event

  if @stack_deletion_completed
    puts "Stack #{@stack_name} deleted."
    return
  end

  success = false
  if last_event_status =~ /_FAILED/
    puts "Stack failed: #{last_event_status}".color(:red)
    puts "Stack reason #{@events[0]["resource_status_reason"]}".color(:red)
  elsif last_event_status =~ /_ROLLBACK_/
    puts "Stack rolled back: #{last_event_status}".color(:red)
  else # success
    puts "Stack success status: #{last_event_status}".color(:green)
    success = true
  end

  # Never gets here when deleting a stack because the describe stack returns nothing
  # once the stack is deleted. Gets here for stack create and update though.
  return if @hide_time_took # set in run
  took = Time.now - start_time
  puts "Time took for stack deployment: #{pretty_time(took).color(:green)}."

  success
end