ec2ctl 0.9.10 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5dab3ddeac4018a3031e936b10a76e691dd0d05
4
- data.tar.gz: 25ddb0b8b1b57f6141a60f0087a447adbd36a266
3
+ metadata.gz: 8190dd5c5a7d325b0882de02a868fcc98b9c15be
4
+ data.tar.gz: 2a8bcdb4cd54ba1d9302b48f6296901fbbc1b6f1
5
5
  SHA512:
6
- metadata.gz: 26698b541f6ef89a600af5ff0a153cb8121a670749bd14bb6f05fdd125fd7406c674fe83159ed6bb2246ab0527c96e4e086609480a17e4d4c45c8fee56e58a24
7
- data.tar.gz: 9930e4a4e93b9d780c5571a3c1a550f23292b2c6c027281bf76010ed74c8fd91e40ebf4fc2f2f92eacc0724db13adb65c7cb1c6e9e664759b2a9e5635b81343e
6
+ metadata.gz: be12a5a68bea03650fd3b48ef9986404707365f708e5db7709f332d9ffe7077531e429c7ea060241094792a84ccbf925b397b139555abb0e95792db14f7512ef
7
+ data.tar.gz: 0a5d2ceb8917311f5610ee7c7d83c8716bc78c8f22ef69d1daff1d3613085fad557cff408b2a2be41a718219a7b8a68e4cefa23547c28f37cdba3aa123cc6413
data/lib/ec2ctl/cli.rb CHANGED
@@ -40,6 +40,7 @@ module EC2Ctl
40
40
  c.option "-C", "--count", "(Optional) Display instance attribute stats."
41
41
  c.option "--platform-type Linux|Windows", String, "(Optional) Platform type: `Linux` or `Windows`. Default is `Linux`."
42
42
  c.option "-S", "--sort KEY", String, "(Optional) Sort instances by this attribute."
43
+ c.option "--private-key-file PATH", String, "(Optional) Path to private key file."
43
44
 
44
45
  c.action do |args, options|
45
46
  invoke c, options do
data/lib/ec2ctl/client.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "aws-sdk"
2
2
  require "timeout"
3
+ require "base64"
4
+ require "openssl"
3
5
 
4
6
  module EC2Ctl
5
7
  class Client
@@ -7,6 +9,7 @@ module EC2Ctl
7
9
  CommandNotSucceeded = Class.new RuntimeError
8
10
  NoInstanceForExecCommand = Class.new RuntimeError
9
11
  InvalidFilter = Class.new RuntimeError
12
+ PrivateKeyRequired = Class.new RuntimeError
10
13
 
11
14
  INSTANCE_IDS_LIMIT = 50
12
15
  COMMAND_STATUS_FINISHED = %w(Success TimedOut Cancelled Failed).freeze
@@ -44,7 +47,8 @@ module EC2Ctl
44
47
  attributes: [],
45
48
  search: [],
46
49
  count: false,
47
- sort: nil
50
+ sort: nil,
51
+ private_key_file: nil
48
52
  )
49
53
  @logger = logger
50
54
 
@@ -77,6 +81,7 @@ module EC2Ctl
77
81
  @search = search
78
82
  @count = count
79
83
  @sort = sort
84
+ @private_key_file = private_key_file
80
85
 
81
86
  if @load_balancer_name
82
87
  @elb_instance_ids = elb_instance_states.map(&:instance_id).select do |instance_id|
@@ -590,6 +595,11 @@ module EC2Ctl
590
595
  if ssm_instance_state
591
596
  query_struct(ssm_instance_state, attribute.split(":")[1..-1].join(":"))
592
597
  end
598
+ when /\Apassword\z/i
599
+ fail PrivateKeyRequired, "Private key required to decrypt password" unless @private_key_file
600
+ @private_key = OpenSSL::PKey::RSA.new(File.read(File.expand_path(@private_key_file))) unless @private_key
601
+
602
+ @private_key.private_decrypt Base64.decode64(instance.password_data.password_data)
593
603
  else
594
604
  query_struct(instance.data, attribute)
595
605
  end
@@ -1,3 +1,3 @@
1
1
  module EC2Ctl
2
- VERSION = "0.9.10"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2ctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoriki Yamaguchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk