class CFnDK::StackCommand

Public Instance Methods

create() click to toggle source
# File lib/cfndk/stack_command.rb, line 15
def create
  CFnDK.logger.info 'create...'.color(:green)
  data = load_config_data(options)
  credentials = resolve_credential(data, options)
  global_config = CFnDK::GlobalConfig.new(data, options)
  stacks = CFnDK::Stacks.new(data, options, credentials)
  
  global_config.pre_command_execute
  stacks.pre_command_execute
  stacks.validate
  stacks.create
  stacks.post_command_execute
  global_config.post_command_execute
  return 0
rescue => e
  CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
  e.backtrace_locations.each do |line|
    CFnDK.logger.debug line
  end
  return 1
end
destroy() click to toggle source
# File lib/cfndk/stack_command.rb, line 65
def destroy
  CFnDK.logger.info 'destroy...'.color(:green)
  data = load_config_data(options)
  credentials = resolve_credential(data, options)

  stacks = CFnDK::Stacks.new(data, options, credentials)

  if options[:force] || yes?('Are you sure you want to destroy? (y/n)', :yellow)
    stacks.destroy
    return 0
  else
    CFnDK.logger.info 'destroy command was canceled'.color(:green)
    return 2
  end
rescue => e
  CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
  e.backtrace_locations.each do |line|
    CFnDK.logger.debug line
  end
  return 1
end
report() click to toggle source
# File lib/cfndk/stack_command.rb, line 112
def report
  CFnDK.logger.info 'report...'.color(:green)
  data = load_config_data(options)
  credentials = resolve_credential(data, options)

  stacks = CFnDK::Stacks.new(data, options, credentials)
  stacks.report
  return 0
rescue => e
  CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
  e.backtrace_locations.each do |line|
    CFnDK.logger.debug line
  end
  return 1
end
update() click to toggle source
# File lib/cfndk/stack_command.rb, line 40
def update
  CFnDK.logger.info 'update...'.color(:green)
  data = load_config_data(options)
  credentials = resolve_credential(data, options)
  global_config = CFnDK::GlobalConfig.new(data, options)
  stacks = CFnDK::Stacks.new(data, options, credentials)

  global_config.pre_command_execute
  stacks.pre_command_execute
  stacks.validate
  stacks.update
  stacks.post_command_execute
  global_config.post_command_execute
  return 0
rescue => e
  CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
  e.backtrace_locations.each do |line|
    CFnDK.logger.debug line
  end
  return 1
end
validate() click to toggle source
# File lib/cfndk/stack_command.rb, line 88
def validate
  CFnDK.logger.info 'validate...'.color(:green)
  data = load_config_data(options)
  credentials = resolve_credential(data, options)
  global_config = CFnDK::GlobalConfig.new(data, options)
  stacks = CFnDK::Stacks.new(data, options, credentials)

  global_config.pre_command_execute
  stacks.pre_command_execute
  stacks.validate
  stacks.post_command_execute
  global_config.post_command_execute
  return 0
rescue => e
  CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
  e.backtrace_locations.each do |line|
    CFnDK.logger.debug line
  end
  return 1
end