aws_su 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/aws_su/version.rb +1 -1
- data/lib/aws_su.rb +7 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38274fd3d81eeb1691305a022ca15555148d7b9d0bb183b7870cbe2d28552a60
|
4
|
+
data.tar.gz: 7639c68250b27a195891918d8ca6e03ecba6952ebb05f5b2ecb2c052725f4e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fe27a01ce97cb4bc279f8b65817fed123e5358fd34c3b217bee693119afbef1d497d5ac1fbbec942df4b001e4eea14c0b19ad826d7c2f2a5aba217d9ff0c86d
|
7
|
+
data.tar.gz: 962cb7617372e0f69973e7da90880c59f905230887dc1dc6f1b76e5ac3536038112b30c624d42e49962af474d2e22b17c1acf4dedb48c2622990bf211d6b3230
|
data/CHANGELOG.md
CHANGED
@@ -30,4 +30,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
30
30
|
|
31
31
|
## [0.1.6] - 03-12-2018
|
32
32
|
### Removed
|
33
|
-
- export of AWS_PROFILE
|
33
|
+
- export of AWS_PROFILE
|
34
|
+
|
35
|
+
## [0.1.7] - 03-12-2018
|
36
|
+
### Changed
|
37
|
+
- For MFA, export awssudo file
|
38
|
+
- For existing session, export sts creds
|
data/lib/aws_su/version.rb
CHANGED
data/lib/aws_su.rb
CHANGED
@@ -66,7 +66,6 @@ module AwsSu
|
|
66
66
|
@region = options[:region].nil? ? region : options[:region]
|
67
67
|
raise('Unable to determine region') if @region.nil?
|
68
68
|
|
69
|
-
export_aws_sudo_file
|
70
69
|
assume_role
|
71
70
|
end
|
72
71
|
|
@@ -110,19 +109,19 @@ module AwsSu
|
|
110
109
|
def assume_role(duration = DURATION)
|
111
110
|
if session_valid?
|
112
111
|
# Recover persisted session and use that to update AWS.config
|
113
|
-
Aws.config.update(
|
112
|
+
config = Aws.config.update(
|
114
113
|
credentials: Aws::Credentials.new(
|
115
114
|
parse_access_key,
|
116
115
|
parse_secret_access_key,
|
117
116
|
parse_session_token
|
118
117
|
)
|
119
118
|
)
|
119
|
+
export_config_to_environment(config)
|
120
120
|
else
|
121
121
|
# Session has expired so auth again
|
122
122
|
assume_role_mfa(duration)
|
123
|
+
export_aws_sudo_file
|
123
124
|
end
|
124
|
-
# For the benefit of anything downstream we are running
|
125
|
-
export_aws_sudo_file
|
126
125
|
end
|
127
126
|
|
128
127
|
# Assume a role using an MFA Token
|
@@ -175,10 +174,10 @@ module AwsSu
|
|
175
174
|
|
176
175
|
# Export the AWS values to the ENV
|
177
176
|
def export_config_to_environment(config)
|
178
|
-
ENV['AWS_ACCESS_KEY_ID'] = config
|
179
|
-
ENV['AWS_SECRET_ACCESS_KEY'] = config
|
180
|
-
ENV['AWS_SESSION_TOKEN'] = config
|
181
|
-
ENV['AWS_SECURITY_TOKEN'] = config
|
177
|
+
ENV['AWS_ACCESS_KEY_ID'] = config[:credentials].access_key_id
|
178
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = config[:credentials].secret_access_key
|
179
|
+
ENV['AWS_SESSION_TOKEN'] = config[:credentials].session_token
|
180
|
+
ENV['AWS_SECURITY_TOKEN'] = config[:credentials].session_token
|
182
181
|
ENV['AWS_TOKEN_TTL'] = @token_ttl
|
183
182
|
ENV['AWS_DEFAULT_REGION'] = @region
|
184
183
|
end
|