Class: CfnCli::Event

Inherits:
Object
  • Object
show all
Includes:
CfnStates
Defined in:
lib/cfncli/event.rb

Constant Summary collapse

RESOURCE_CREATE_INITIATED =
'Resource creation Initiated'.freeze
AWS_STACK_RESOURCE =
'AWS::CloudFormation::Stack'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CfnStates

#failed?, #failed_states, #finished?, #finished_states, #in_progress?, #states, #succeeded?, #success_states, #transitive_states

Constructor Details

#initialize(event) ⇒ Event

Returns a new instance of Event.



12
13
14
# File 'lib/cfncli/event.rb', line 12

def initialize(event)
  @event = event
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



7
8
9
# File 'lib/cfncli/event.rb', line 7

def event
  @event
end

Instance Method Details

#child_stack_create_event?Boolean

Check if the current event has the signature of a child stack creation

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/cfncli/event.rb', line 27

def child_stack_create_event?
  return false unless in_progress?
  return false unless event.resource_type == AWS_STACK_RESOURCE
  return false unless event.resource_status_reason == RESOURCE_CREATE_INITIATED
  true
end

#colorObject



20
21
22
23
24
# File 'lib/cfncli/event.rb', line 20

def color
  return :green if succeeded?
  return :yellow if in_progress?
  return :red if failed?
end

#statusObject



16
17
18
# File 'lib/cfncli/event.rb', line 16

def status
  event.resource_status
end

#to_sObject



34
35
36
# File 'lib/cfncli/event.rb', line 34

def to_s
  "#{event.timestamp} #{event.resource_status} #{event.resource_type} #{event.logical_resource_id} #{event.resource_status_reason}"
end