Class: CFnDK::StackCommand

Inherits:
Thor
  • Object
show all
Includes:
ConfigFileLoadable, SubcommandHelpReturnable
Defined in:
lib/cfndk/stack_command.rb

Instance Method Summary collapse

Methods included from SubcommandHelpReturnable

included

Methods included from CFnDK::SubcommandHelpReturnable::ClassMethods

#subcommand_help

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cfndk/stack_command.rb', line 14

def create
  CFnDK.logger.info 'create...'.color(:green)
  data = load_config_data(options)

  credentials = CFnDK::CredentialProviderChain.new.resolve
  stacks = CFnDK::Stacks.new(data, options, credentials)
  stacks.validate
  stacks.create
  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

#destroyObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/cfndk/stack_command.rb', line 54

def destroy
  CFnDK.logger.info 'destroy...'.color(:green)
  data = load_config_data(options)

  credentials = CFnDK::CredentialProviderChain.new.resolve
  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

#reportObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/cfndk/stack_command.rb', line 95

def report
  CFnDK.logger.info 'report...'.color(:green)
  data = load_config_data(options)
  credentials = CFnDK::CredentialProviderChain.new.resolve
  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

#updateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cfndk/stack_command.rb', line 34

def update
  CFnDK.logger.info 'update...'.color(:green)
  data = load_config_data(options)

  credentials = CFnDK::CredentialProviderChain.new.resolve
  stacks = CFnDK::Stacks.new(data, options, credentials)
  stacks.validate
  stacks.update
  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

#validateObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cfndk/stack_command.rb', line 77

def validate
  CFnDK.logger.info 'validate...'.color(:green)
  data = load_config_data(options)
  credentials = CFnDK::CredentialProviderChain.new.resolve
  stacks = CFnDK::Stacks.new(data, options, credentials)
  stacks.validate
  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