ec2-host 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab82e2af1189495aec002dcbce61337e9a0f0af5
4
- data.tar.gz: 3c464dd9a3c42773f4acfa2e385d58152e9e15de
3
+ metadata.gz: 75292280f46832c3bd111dfd551e7a00f7c27835
4
+ data.tar.gz: 3b50f9114115995051b2fcd7a2936c0b6db5aafa
5
5
  SHA512:
6
- metadata.gz: ebb7e3cb363e5d04a827bf9a89b46baa155e8b4e1a766c476dc2b74a95d03d1de9aeafb54e68a4a9588ae6189e8cc93e06403443191b49997071ba2e854b8c76
7
- data.tar.gz: c1cc99a1c363d9f8568050fb458fd0ff1c0617d11501bd1d4d0357050063342c2e5c50d995a471d3aef73716d6fd74e7d725885d3f9a0dc49b2c5fe26f52d9c9
6
+ metadata.gz: 9b66044d377be0f98cbd525b60537861c2b342e753adb8abbb59de2bc5a1fd4b62bc61c18424fc2fc466a555a440e873657e883b52f053ca5e90936aaffe9ff5
7
+ data.tar.gz: 4784cd6f17633fc99f8387bed28baa80d011d902eb5144f82c71eff4a78819c0de97724154ce34f620341f654111783658f4c414c19823a7ad60989bd315e7b1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.4.1 (2016/11/24)
2
+
3
+ Enhancements:
4
+
5
+ * Get AWS_REGION from ~/.aws/config as default
6
+ * Fix default of AWS_PROFILE was set to 'nil' rather than nil
7
+
1
8
  # 0.4.0 (2016/11/24)
2
9
 
3
10
  Enhancements:
data/README.md CHANGED
@@ -23,7 +23,7 @@ AWS SDK (CLI) parameters:
23
23
 
24
24
  * **AWS_ACCESS_KEY_ID**: AWS SDK (CLI) crendentials. Default loads a credentials file
25
25
  * **AWS_SECRET_ACCESS_KEY**: AWS SDK (CLI) credentials. Default load a credentials file
26
- * **AWS_DEFAULT_REGION** (**AWS_REGION**); AWS SDK (CLI) region such as `ap-northeast-1`, `us-east-1`.
26
+ * **AWS_DEFAULT_REGION** (**AWS_REGION**); AWS SDK (CLI) region such as `ap-northeast-1`, `us-east-1`. Default obtains from `$HOME/.aws/config` with profile `AWS_DEFAULT_PROFILE`.
27
27
  * **AWS_DEFAULT_PROFILE** (**AWS_PROFILE**): The profile key of the AWS SDK (CLI) credentails file. Default is `default`
28
28
  * **AWS_CREDENTIAL_FILE** (**AWS_CREDENTIALS_FILE**): Path of the AWS SDK (CLI) credentails file. Default is `$HOME/.aws/credentials`. See [Configuring the AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) for details.
29
29
 
data/ec2-host.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "ec2-host"
3
- gem.version = '0.4.0'
3
+ gem.version = '0.4.1'
4
4
  gem.author = ['Naotoshi Seo']
5
5
  gem.email = ['sonots@gmail.com']
6
6
  gem.homepage = 'https://github.com/sonots/ec2-host'
@@ -10,11 +10,13 @@ Gem::Specification.new do |gem|
10
10
 
11
11
  gem.files = `git ls-files`.split("\n")
12
12
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.bindir = "exe"
14
+ gem.executables = `git ls-files -- exe/*`.split("\n").map{ |f| File.basename(f) }
14
15
  gem.require_paths = ["lib"]
15
16
 
16
17
  gem.add_runtime_dependency 'aws-sdk'
17
18
  gem.add_runtime_dependency 'dotenv'
19
+ gem.add_runtime_dependency 'inifile'
18
20
 
19
21
  gem.add_development_dependency 'yard'
20
22
  gem.add_development_dependency 'rdoc'
File without changes
@@ -1,3 +1,4 @@
1
+ require 'inifile'
1
2
  require 'dotenv'
2
3
  Dotenv.load
3
4
 
@@ -31,12 +32,13 @@ class EC2
31
32
  def self.aws_region
32
33
  @aws_region ||=
33
34
  ENV['AWS_REGION'] || config.fetch('AWS_REGION', nil) || # ref. old aws cli
34
- ENV['AWS_DEFAULT_REGION'] || config.fetch('AWS_DEFAULT_REGION') # ref. aws cli and terraform
35
+ ENV['AWS_DEFAULT_REGION'] || config.fetch('AWS_DEFAULT_REGION', nil) || # ref. aws cli and terraform
36
+ aws_config['region'] || raise('AWS_REGION nor AWS_DEFAULT_REGION is not set')
35
37
  end
36
38
 
37
39
  def self.aws_profile
38
40
  @aws_profile ||=
39
- ENV['AWS_PROFILE'] || config.fetch('AWS_PROFILE', 'nil') || # ref. old aws cli
41
+ ENV['AWS_PROFILE'] || config.fetch('AWS_PROFILE', nil) || # ref. old aws cli
40
42
  ENV['AWS_DEFAULT_PROFILE'] || config.fetch('AWS_DEFAULT_PROFILE', 'default') # ref. aws cli and terraform
41
43
  end
42
44
 
@@ -53,7 +55,25 @@ class EC2
53
55
  def self.aws_credential_file
54
56
  @aws_credential_file ||=
55
57
  ENV['AWS_CREDENTIALS_FILE'] || config.fetch('AWS_CREDENTIALS_FILE', nil) ||
56
- ENV['AWS_CREDENTIAL_FILE'] || config.fetch('AWS_CREDENTIAL_FILE', nil) # ref. aws cli (supported lately)
58
+ ENV['AWS_CREDENTIAL_FILE'] || config.fetch('AWS_CREDENTIAL_FILE', nil) || # ref. aws cli (supported lately)
59
+ File.expand_path('~/.aws/credentials')
60
+ end
61
+
62
+ def self.aws_config_file
63
+ @aws_config_file ||= ENV['AWS_CONFIG_FILE'] || config.fetch('AWS_CONFIG_FILE', nil) || File.expand_path('~/.aws/config')
64
+ end
65
+
66
+ def self.aws_config
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
75
+ end
76
+ @aws_config ||= {}
57
77
  end
58
78
 
59
79
  def self.log_level
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: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: inifile
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: yard
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +179,6 @@ files:
165
179
  - LICENSE
166
180
  - README.md
167
181
  - Rakefile
168
- - bin/ec2-host
169
182
  - docs/EC2.html
170
183
  - docs/EC2/Host.html
171
184
  - docs/EC2/Host/CLI.html
@@ -194,6 +207,7 @@ files:
194
207
  - example/aws-sdk.rb
195
208
  - example/example.conf
196
209
  - example/example.rb
210
+ - exe/ec2-host
197
211
  - lib/ec2-host.rb
198
212
  - lib/ec2/host.rb
199
213
  - lib/ec2/host/cli.rb