This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from kickstarter/ec2-instance-connect
EC2 instance connect init
- Loading branch information
Showing
5 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class HiveQueen | ||
def self.ec2_client | ||
@ec2_client ||= Aws::EC2::Client.new | ||
end | ||
|
||
def self.ec2_instance_connect_client | ||
@ec2_instance_connect_client ||= Aws::EC2InstanceConnect::Client.new | ||
end | ||
|
||
def self.ec2_instance_connect(*private_dns) | ||
# EC2 Instance Connect | ||
ssh_public_key = File.read(File.expand_path('~/.ssh/ksr_ed25519.pub')) | ||
ec2_params = { | ||
filters: [{ | ||
name: 'network-interface.private-dns-name', | ||
values: private_dns | ||
}] | ||
} | ||
logger.trace("ec2:DescribeInstances #{ec2_params.to_json}") | ||
instances = ec2_client.describe_instances(**ec2_params).reservations.map(&:instances).flatten | ||
threads = instances.map do |instance| | ||
Thread.new do | ||
ec2ic_params = { | ||
availability_zone: instance.placement.availability_zone, | ||
instance_id: instance.instance_id, | ||
instance_os_user: 'ksr', | ||
ssh_public_key: ssh_public_key, | ||
} | ||
logger.trace("ec2-instance-connect:SendSSHPublicKey #{ec2ic_params.to_json}") | ||
ec2_instance_connect_client.send_ssh_public_key(**ec2ic_params) | ||
end | ||
end | ||
|
||
threads.each(&:join) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
class HiveQueen | ||
class Version | ||
@@version = '7.6.0' | ||
@@version = '7.7.0' | ||
|
||
def self.to_s | ||
@@version | ||
|