Class: Awful::Keypair

Inherits:
Cli show all
Defined in:
lib/awful/keypair.rb

Instance Method Summary collapse

Methods inherited from Cli

#initialize

Constructor Details

This class inherits a constructor from Awful::Cli

Instance Method Details

#create(name) ⇒ Object



23
24
25
26
27
# File 'lib/awful/keypair.rb', line 23

def create(name)
  ec2.create_key_pair(key_name: name.to_s).output do |k|
    puts k.key_material
  end
end

#delete(name) ⇒ Object



37
38
39
40
41
# File 'lib/awful/keypair.rb', line 37

def delete(name)
  if yes?("Really delete key pair #{name}?", :yellow)
    ec2.delete_key_pair(key_name: name)
  end
end

#import(name) ⇒ Object



31
32
33
34
# File 'lib/awful/keypair.rb', line 31

def import(name)
  key = file_or_stdin(options[:file])
  ec2.import_key_pair(key_name: name, public_key_material: key)
end

#ls(*names) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/awful/keypair.rb', line 11

def ls(*names)
  names = nil if names.empty?
  ec2.describe_key_pairs(key_names: names).key_pairs.output do |kp|
    if options[:long]
      print_table kp.map{ |k| [k.key_name, k.key_fingerprint] }
    else
      puts kp.map(&:key_name)
    end
  end
end