awsclient 0.1.5 → 0.1.6

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: 7dd5b9046ae390b476d3de118c2a14477c9a2b7d
4
- data.tar.gz: e41e7bcdbf958cff86b58dcc9ec8e93a308cdf38
3
+ metadata.gz: c05f6937e07cc10242c8d911a96bff335676b97a
4
+ data.tar.gz: 45947da23ed7875623116ebcaddb760484d768d3
5
5
  SHA512:
6
- metadata.gz: cf05b0a747904bbfe125f94e54b72c272e1cc55790cf6c06043653a2415005a0714805c0811554a825503d601125d7a7c816a517a881c3e3148ca444df4dbee5
7
- data.tar.gz: a8ada7183f1c7c63caeb056d873b187e1059acd2cb77fad224e1c5bd3995d83fae823c9e8590efcda570f129072473cd6d2be25c4f6699b335b79e396aee2ed4
6
+ metadata.gz: 54a3f7f5beb7229e070c148c0e5622a24f299bc9752a619e9078f0e6dcdb8b48ede4fce24e108c875339b46ddb1caaf2ed9a9c39501d3beef6ecaa4acc9df6d1
7
+ data.tar.gz: 9b1c52ad34ac91cab86667fe68ea64684fc311593c76b6e286ad343d1be76ed3044438b845abb4b99d1989e3c17b4be838270fa8d29c4ed3fc0a859e09b05947
@@ -43,7 +43,10 @@ module Awsclient
43
43
 
44
44
  def load_credentials(profile_name='default')
45
45
  creds = ::Aws::SharedCredentials.new(profile_name: profile_name)
46
- return creds if creds.set?
46
+ if creds.set?
47
+ load_region_from_profile(profile_name)
48
+ return creds
49
+ end
47
50
  instance_profile_credentials
48
51
  end
49
52
 
@@ -74,11 +77,12 @@ module Awsclient
74
77
  end
75
78
 
76
79
  def profile=(profile_name)
80
+ load_region_from_profile(profile_name)
77
81
  self.credentials = ::Aws::SharedCredentials.new(profile_name: profile_name)
78
82
  end
79
83
 
80
84
  def region
81
- @region ||= client_options[:region] || 'us-east-1'
85
+ @region ||= (client_options[:region] || 'us-east-1')
82
86
  end
83
87
 
84
88
  def underscored_region
@@ -551,5 +555,11 @@ module Awsclient
551
555
  (0...length).map { o[rand(o.length)] }.join
552
556
  end
553
557
 
558
+ def load_region_from_profile(profile_name)
559
+ awsconfig = File.read("#{ENV['HOME']}/.aws/config")
560
+ matcher = awsconfig.match(/\[profile\s#{profile_name}\]\r?\n?region\s*=(.*)/)
561
+ @region = matcher[1] if matcher
562
+ end
563
+
554
564
  end
555
565
  end
@@ -1,3 +1,3 @@
1
1
  module Awsclient
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Hahn