ec2-host 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +8 -2
- data/ec2-host.gemspec +1 -1
- data/lib/ec2/host/config.rb +5 -8
- data/lib/ec2/host/ec2_client.rb +16 -1
- data/lib/ec2/host/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f749471944700121c781943703aa72e8b8a07d9
|
4
|
+
data.tar.gz: 9db09c8155b61efb38851d579740fb809ce30aab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1098d2a578af8b30dab95e87ebe1f4b89e23bfab7f8bf51370549051413c75756ce38f210e98fcabb28f325a01f5be399e0229922f11d5683b2a8079c3d016
|
7
|
+
data.tar.gz: e5a6fe2fae9935252dc4af230c3726fec9a43bb1824e7e11cae1615f6d03be85499b0e397f5dc19b4bb9e603ff2d219c0b78e90e065b1f4a09bfb469b3fbdb12
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
# 1.0.1 (2019/02/05)
|
2
|
+
|
3
|
+
Enhancements:
|
4
|
+
|
5
|
+
* Support assume role credential and instance profile (thanks to @toyama0919)
|
6
|
+
|
1
7
|
# 1.0.0 (2018/12/04)
|
2
8
|
|
3
|
-
|
9
|
+
Breaking changes:
|
4
10
|
|
5
|
-
*
|
11
|
+
* Upgrade aws-sdk to v3, using aws-sdk-ec2.
|
6
12
|
|
7
13
|
# 0.6.0 (2017/05/20)
|
8
14
|
|
data/ec2-host.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.add_runtime_dependency 'aws-sdk-ec2'
|
20
20
|
gem.add_runtime_dependency 'dotenv'
|
21
|
-
gem.add_runtime_dependency '
|
21
|
+
gem.add_runtime_dependency 'aws_config'
|
22
22
|
|
23
23
|
gem.add_development_dependency 'yard'
|
24
24
|
gem.add_development_dependency 'rdoc'
|
data/lib/ec2/host/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'inifile'
|
2
1
|
require 'dotenv'
|
2
|
+
require 'aws_config'
|
3
3
|
Dotenv.load
|
4
4
|
|
5
5
|
class EC2
|
@@ -65,13 +65,10 @@ class EC2
|
|
65
65
|
|
66
66
|
def self.aws_config
|
67
67
|
return @aws_config if @aws_config
|
68
|
-
if File.readable?(aws_config_file)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
else
|
73
|
-
@aws_config = ini["profile #{aws_profile}"]
|
74
|
-
end
|
68
|
+
if File.readable?(aws_config_file) && File.readable?(aws_credential_file)
|
69
|
+
AWSConfig.config_file = aws_config_file
|
70
|
+
AWSConfig.credentials_file = aws_credential_file
|
71
|
+
@aws_config = AWSConfig[aws_profile]
|
75
72
|
end
|
76
73
|
@aws_config ||= {}
|
77
74
|
end
|
data/lib/ec2/host/ec2_client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'aws-sdk-ec2'
|
3
|
+
require 'aws-sdk-sts'
|
3
4
|
|
4
5
|
class EC2
|
5
6
|
class Host
|
@@ -38,7 +39,21 @@ class EC2
|
|
38
39
|
if Config.aws_access_key_id and Config.aws_secret_access_key
|
39
40
|
Aws::Credentials.new(Config.aws_access_key_id, Config.aws_secret_access_key)
|
40
41
|
else
|
41
|
-
|
42
|
+
aws_config = Config.aws_config
|
43
|
+
if aws_config[:role_arn]
|
44
|
+
Aws::AssumeRoleCredentials.new(
|
45
|
+
client: Aws::STS::Client.new(aws_config.config_hash),
|
46
|
+
role_arn: aws_config[:role_arn],
|
47
|
+
role_session_name: "ec2-host-session-#{Time.now.to_i}"
|
48
|
+
)
|
49
|
+
elsif aws_config[:credential_source] == "Ec2InstanceMetadata"
|
50
|
+
Aws::InstanceProfileCredentials.new
|
51
|
+
else
|
52
|
+
Aws::SharedCredentials.new(
|
53
|
+
profile_name: Config.aws_profile,
|
54
|
+
path: Config.aws_credential_file
|
55
|
+
)
|
56
|
+
end
|
42
57
|
end
|
43
58
|
end
|
44
59
|
|
data/lib/ec2/host/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2-host
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-ec2
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: aws_config
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
requirements: []
|
245
245
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.
|
246
|
+
rubygems_version: 2.5.2.3
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
249
|
summary: Search hosts on AWS EC2
|