Class: Composer::Verify::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/composer/verify/key.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Key

Returns a new instance of Key.



4
5
6
7
8
# File 'lib/composer/verify/key.rb', line 4

def initialize(args)
  @config = args[:config]
  @region = @config.region
  @logger = @config.logger
end

Instance Method Details

#verify(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/composer/verify/key.rb', line 10

def verify(args)
  key = args[:key]

  key_pairs = ec2.key_pairs.entries.map { |k| k.name }

  @logger.debug "Check for key_pairs in #{@region}."
  @logger.debug "Existing keypairs: #{key_pairs.join ', '}"

  unless key_pairs.include? key
    raise InvalidKeyPair.new "Key #{key} does not exist in #{@region}."
  end
end