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 +4 -4
- data/lib/awsclient.rb +12 -2
- data/lib/awsclient/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c05f6937e07cc10242c8d911a96bff335676b97a
|
4
|
+
data.tar.gz: 45947da23ed7875623116ebcaddb760484d768d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a3f7f5beb7229e070c148c0e5622a24f299bc9752a619e9078f0e6dcdb8b48ede4fce24e108c875339b46ddb1caaf2ed9a9c39501d3beef6ecaa4acc9df6d1
|
7
|
+
data.tar.gz: 9b1c52ad34ac91cab86667fe68ea64684fc311593c76b6e286ad343d1be76ed3044438b845abb4b99d1989e3c17b4be838270fa8d29c4ed3fc0a859e09b05947
|
data/lib/awsclient.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/awsclient/version.rb
CHANGED