Class: Kitchen::Driver::Aws::InstanceConnect
- Inherits:
-
Object
- Object
- Kitchen::Driver::Aws::InstanceConnect
- Defined in:
- lib/kitchen/driver/aws/instance_connect.rb
Overview
Pushes short-lived SSH public keys to an instance using EC2 Instance Connect, so that a connection can be made without a long-lived key pair.
A pushed key is accepted for roughly sixty seconds, so it is sent again before each connection rather than once at create time.
Instance Method Summary collapse
-
#initialize(config, logger) ⇒ InstanceConnect
constructor
A new instance of InstanceConnect.
-
#send_ssh_public_key(instance_id, username, public_key) ⇒ void
Push an SSH public key to an instance for a given user.
Constructor Details
#initialize(config, logger) ⇒ InstanceConnect
Returns a new instance of InstanceConnect.
30 31 32 33 34 |
# File 'lib/kitchen/driver/aws/instance_connect.rb', line 30 def initialize(config, logger) @config = config @logger = logger @client = ::Aws::EC2InstanceConnect::Client.new(region: config[:region]) end |
Instance Method Details
#send_ssh_public_key(instance_id, username, public_key) ⇒ void
This method returns an undefined value.
Push an SSH public key to an instance for a given user.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kitchen/driver/aws/instance_connect.rb', line 45 def send_ssh_public_key(instance_id, username, public_key) @logger.info("Sending SSH public key to instance #{instance_id} for user #{username}") @client.send_ssh_public_key({ instance_id: instance_id, instance_os_user: username, ssh_public_key: public_key, availability_zone: @config[:availability_zone], }) @logger.debug("SSH public key successfully sent to instance") end |