class AWS::EC2::KeyPair
Represents an EC2
key pair. @attr_reader [String] fingerprint A SHA-1 digest of the DER encoded
private key
Attributes
name[R]
@return [String] The name of the key pair.
Public Class Methods
new(name, options = {})
click to toggle source
Calls superclass method
# File lib/aws/ec2/key_pair.rb, line 22 def initialize name, options = {} @name = name.to_s @private_key = options[:private_key] super end
Public Instance Methods
delete()
click to toggle source
Deletes this key pair from EC2
. @return [true]
# File lib/aws/ec2/key_pair.rb, line 65 def delete client.delete_key_pair(:key_name => name) true end
exists?()
click to toggle source
@return [Boolean] True if the key pair exists.
# File lib/aws/ec2/key_pair.rb, line 42 def exists? resp = client.describe_key_pairs(:filters => [ { :name => "key-name", :values => [name] } ]) !resp.key_set.empty? end
private_key()
click to toggle source
Returns the private key. Raises an exception if called against an existing key. You can only get the private key at the time of creation.
@see KeyPairCollection#import
@note Only call this method on newly created keys. @return [String] An unencrypted PEM encoded RSA private key.
# File lib/aws/ec2/key_pair.rb, line 56 def private_key unless @private_key raise 'you can only get the private key for just-created keypairs' end @private_key end
Protected Instance Methods
find_in_response(resp)
click to toggle source
# File lib/aws/ec2/key_pair.rb, line 76 def find_in_response(resp) resp.key_index[name] end
response_id_method()
click to toggle source
# File lib/aws/ec2/key_pair.rb, line 71 def response_id_method :key_name end