Class: Jackal::Cfn::Formatter::ChefCleanup

Inherits:
Formatter
  • Object
show all
Defined in:
lib/jackal-cfn/formatter/chef_cleanup.rb

Overview

Add cleanup information for chef instances

Constant Summary collapse

SOURCE =

Source service

:cfn
DESTINATION =

Destination service

:commander

Instance Method Summary collapse

Instance Method Details

#format(payload) ⇒ Object

Format payload to enable knife scrubbing via commander

Parameters:

  • payload (Smash)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jackal-cfn/formatter/chef_cleanup.rb', line 19

def format(payload)
  event = payload.get(:data, :cfn_event)
  if(valid_event?(event))
    stack_id = payload.get(:data, :cfn_event, :stack_id)
    if(stack_id)
      debug "Found stack ID information. Setting commander scrub commands. (Stack ID: #{stack_id})"
      actions = payload.fetch(:data, :commander, :actions, [])
      actions << Smash.new(
        :name => app_config.fetch(:cfn, :formatter, :chef_cleanup_command, :chef_cleanup),
        :arguments => stack_id
      )
      payload.set(:data, :commander, :actions, actions)
    end
  end
end

#valid_event?(event) ⇒ Truthy, Falsey

Determine validity of event

Parameters:

  • event (Smash)

Returns:

  • (Truthy, Falsey)


39
40
41
42
# File 'lib/jackal-cfn/formatter/chef_cleanup.rb', line 39

def valid_event?(event)
  event[:resource_status] == 'DELETE_COMPLETE' &&
    event[:resource_type] == app_config.fetch(:cfn, :formatter, :stack_resource_type, 'AWS::CloudFormation::Stack')
end