Class: CFnDK::KeyPairCommand

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

Instance Method Summary collapse

Methods included from SubcommandHelpReturnable

included

Methods included from SubcommandHelpReturnable::ClassMethods

#subcommand_help

Instance Method Details

#createObject



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

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

  credentials = CFnDK::CredentialProviderChain.new.resolve
  keypairs = CFnDK::KeyPairs.new(data, options, credentials)
  keypairs.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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cfndk/key_pair_command.rb', line 31

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

  credentials = CFnDK::CredentialProviderChain.new.resolve
  keypairs = CFnDK::KeyPairs.new(data, options, credentials)

  if options[:force] || yes?('Are you sure you want to destroy? (y/n)', :yellow)
    keypairs.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