Represents an EC2 key pair. @attr_reader [String] fingerprint A SHA-1 digest of the DER encoded
private key
@return [String] The name of the key pair.
# File lib/aws/ec2/key_pair.rb, line 22 def initialize name, options = {} @name = name.to_s @private_key = options[:private_key] super end
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
@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
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 AWS::EC2::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
# File lib/aws/ec2/key_pair.rb, line 76 def find_in_response(resp) resp.key_index[name] end
# File lib/aws/ec2/key_pair.rb, line 71 def response_id_method :key_name end