Class: AWS::EC2::KeyPair
- Inherits:
-
Resource
- Object
- Resource
- AWS::EC2::KeyPair
- Defined in:
- lib/aws/ec2/key_pair.rb
Overview
Represents an EC2 key pair.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the key pair.
Instance Method Summary collapse
-
#delete ⇒ true
Deletes this key pair from EC2.
-
#exists? ⇒ Boolean
True if the key pair exists.
-
#fingerprint ⇒ String
A SHA-1 digest of the DER encoded private key.
-
#initialize(name, options = {}) ⇒ KeyPair
constructor
A new instance of KeyPair.
-
#private_key ⇒ String
Returns the private key.
Constructor Details
#initialize(name, options = {}) ⇒ KeyPair
22 23 24 25 26 27 |
# File 'lib/aws/ec2/key_pair.rb', line 22 def initialize name, = {} @name = name.to_s @fingerprint = [:fingerprint] @private_key = [:private_key] super end |
Instance Attribute Details
#name ⇒ String (readonly)
30 31 32 |
# File 'lib/aws/ec2/key_pair.rb', line 30 def name @name end |
Instance Method Details
#delete ⇒ true
Deletes this key pair from EC2.
61 62 63 64 |
# File 'lib/aws/ec2/key_pair.rb', line 61 def delete client.delete_key_pair(:key_name => name) true end |
#exists? ⇒ Boolean
33 34 35 36 37 |
# File 'lib/aws/ec2/key_pair.rb', line 33 def exists? !client.describe_key_pairs(:filters => [{ :name => "key-name", :values => [name] }]). key_set.empty? end |
#fingerprint ⇒ String
40 |
# File 'lib/aws/ec2/key_pair.rb', line 40 def fingerprint; end |
#private_key ⇒ String
Note:
Only call this method on newly created keys.
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.
52 53 54 55 56 57 |
# File 'lib/aws/ec2/key_pair.rb', line 52 def private_key unless @private_key raise 'you can only get the private key for just-created keypairs' end @private_key end |