Class: CfnManage::CloudFormation::ProgressTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/cfn_manage/cf_progress_tracker.rb

Constant Summary collapse

@@default_ending_states =
%w[
  CREATE_COMPLETE
  UPDATE_COMPLETE
  UPDATE_ROLLBACK_COMPLETE
  ROLLBACK_FAILED
  DELETE_FAILED
]
@@default_display_state =
%w[
    CREATE_COMPLETE
    UPDATE_COMPLETE
]

Instance Method Summary collapse

Constructor Details

#initialize(stack_name, period_from, creds = nil, region = nil) ⇒ ProgressTracker

Returns a new instance of ProgressTracker.



27
28
29
30
31
32
33
34
35
# File 'lib/cfn_manage/cf_progress_tracker.rb', line 27

def initialize(stack_name, period_from, creds = nil, region = nil)
  client_params = {}
  client_params['region'] = region unless region.nil?
  client_params['credentials'] = creds unless creds.nil?
  @cf_client = Aws::CloudFormation::Client.new(client_params)
  @stack_name = stack_name
  @ending_statest = @@default_ending_states
  @period_from = period_from
end

Instance Method Details

#track_progress(_show_only_failures = false) ⇒ Object



50
51
52
# File 'lib/cfn_manage/cf_progress_tracker.rb', line 50

def track_progress(_show_only_failures = false)
  Common.visit_stack(@cf_client, @stack_name, method(:track_single_stack),true)
end

#track_single_stack(stack) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cfn_manage/cf_progress_tracker.rb', line 38

def track_single_stack(stack)
  stack_id = stack['stack_id']
  # Default to period_from if first run, take from last run otherwise
  event_from = last_event_times[stack_id] if @last_event_times.key?(stack_id)
  event_from = @period_from unless @last_event_times.key?(stack_id)


  stack_resources = @cf_client.describe_stack_events(stack_name: stack['stack_id'],)


end