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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 3a13e6935752a27033d440cdc5b0b5ae5af4a3b684ddf87bf82c109cfbe25ab7
4
- data.tar.gz: 10b9818eb1428ace6ada0f80b4cc29f1c460ebea6452a9a8fcb662ec255e9dd2
2
+ SHA1:
3
+ metadata.gz: 8f749471944700121c781943703aa72e8b8a07d9
4
+ data.tar.gz: 9db09c8155b61efb38851d579740fb809ce30aab
5
5
  SHA512:
6
- metadata.gz: ddc6f7f6e62dbd638ad061fda97843ecc858b956b45f76042020bc181560567504600f682470d041ad155759b941061a6a1d03f0a9e40133dc3453cb16962084
7
- data.tar.gz: 5688701717d96b582ea90b190e851fdadf2dd1c1ec596abab34f65376ef3fa9a70577248e24ad6fc3b67c1aa597dc3ffa326e3f6ac1de40d7f78c15b7d4b4106
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
- Fixes:
9
+ Breaking changes:
4
10
 
5
- * upgrade aws-sdk v3. use aws-sdk-ec2.
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 'inifile'
21
+ gem.add_runtime_dependency 'aws_config'
22
22
 
23
23
  gem.add_development_dependency 'yard'
24
24
  gem.add_development_dependency 'rdoc'
@@ -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
- ini = IniFile.load(aws_config_file).to_h
70
- if aws_profile == 'default'
71
- @aws_config = ini['default']
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
@@ -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
- Aws::SharedCredentials.new(profile_name: Config.aws_profile, path: Config.aws_credential_file)
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
 
@@ -1,5 +1,5 @@
1
1
  class EC2
2
2
  class Host
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
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.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: 2018-12-04 00:00:00.000000000 Z
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: inifile
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.7.6
246
+ rubygems_version: 2.5.2.3
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: Search hosts on AWS EC2