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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2172196d759f4f640149fa32851613febed321ffe82ba6ae338bb057f3d60b64
4
- data.tar.gz: 1c401004aec775037b3051dc2ccfa2e5d63db0b41b75c098d6fbf8cd133cbedd
3
+ metadata.gz: 38274fd3d81eeb1691305a022ca15555148d7b9d0bb183b7870cbe2d28552a60
4
+ data.tar.gz: 7639c68250b27a195891918d8ca6e03ecba6952ebb05f5b2ecb2c052725f4e68
5
5
  SHA512:
6
- metadata.gz: 9be61d9d1b0c45bd52c16dae0e4ef10691927d5ead93c22cd2cba662b99e3ae0486328b0b9341cfe8c0f3a77b1cfcb5ab5a0a4037bf707e7fff6c62735a4ddcb
7
- data.tar.gz: 19b2f317ca14e0007007acde11ae4d7b754c292f94ee7416859ada9db0d9967fe09514b8d73252261685ad90dde2e4f64a16038fdf742fb008741d3d5f3ed0ec
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AwsSu
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
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.credentials.access_key_id
179
- ENV['AWS_SECRET_ACCESS_KEY'] = config.credentials.secret_access_key
180
- ENV['AWS_SESSION_TOKEN'] = config.credentials.session_token
181
- ENV['AWS_SECURITY_TOKEN'] = config.credentials.session_token
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_su
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Atkins