miasma-aws 0.1.26 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/miasma-aws/version.rb +1 -1
- data/lib/miasma/contrib/aws.rb +41 -16
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07096224821dda2e08f3bda1532073082f12266d
|
4
|
+
data.tar.gz: 3c64010ced9c7dceb1f2c4202946538b76f8fe3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4cde26b9fce70ec6d900b823f7366018a0c075f6a891a0ee7aeddad68b11a1d65b5aa4c661d689d52a04fd4a444dc697f7c05817c35ee367f1a0881624ec995
|
7
|
+
data.tar.gz: bfe73ddbdc975d9f48ee3a01ed1bd7f2c2a1e4736693d21e67fee32bbd5585f1fd20d7054fdda5f910bc5f3d98c030f723578fec2016021edae68a59bb633813
|
data/CHANGELOG.md
CHANGED
data/lib/miasma-aws/version.rb
CHANGED
data/lib/miasma/contrib/aws.rb
CHANGED
@@ -383,7 +383,8 @@ module Miasma
|
|
383
383
|
end
|
384
384
|
end
|
385
385
|
|
386
|
-
#
|
386
|
+
# Provide custom setup functionality to support alternative
|
387
|
+
# credential loading.
|
387
388
|
#
|
388
389
|
# @param creds [Hash]
|
389
390
|
# @return [TrueClass]
|
@@ -410,6 +411,21 @@ module Miasma
|
|
410
411
|
true
|
411
412
|
end
|
412
413
|
|
414
|
+
# Persist any underlying stored credential data that is not a
|
415
|
+
# defined attribute (things like STS information)
|
416
|
+
#
|
417
|
+
# @param creds [Hash]
|
418
|
+
# @return [TrueClass]
|
419
|
+
def after_setup(creds)
|
420
|
+
skip = self.class.attributes.keys.map(&:to_s)
|
421
|
+
creds.each do |k,v|
|
422
|
+
k = k.to_s
|
423
|
+
if(k.start_with?('aws_') && !skip.include?(k))
|
424
|
+
data[k] = v
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
413
429
|
# Attempt to load credentials from instance metadata
|
414
430
|
#
|
415
431
|
# @param creds [Hash]
|
@@ -462,21 +478,23 @@ module Miasma
|
|
462
478
|
creds[:aws_access_key_id_original] = creds[:aws_access_key_id]
|
463
479
|
creds[:aws_secret_access_key_original] = creds[:aws_secret_access_key]
|
464
480
|
end
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
481
|
+
if(sts_update_required?(creds))
|
482
|
+
sts = Miasma::Contrib::Aws::Api::Sts.new(
|
483
|
+
:aws_access_key_id => creds[:aws_access_key_id_original],
|
484
|
+
:aws_secret_access_key => creds[:aws_secret_access_key_original],
|
485
|
+
:aws_region => creds.fetch(:aws_sts_region, 'us-east-1'),
|
486
|
+
:aws_credentials_file => creds.fetch(:aws_credentials_file, aws_credentials_file),
|
487
|
+
:aws_config_file => creds.fetch(:aws_config_file, aws_config_file),
|
488
|
+
:aws_profile_name => creds[:aws_profile_name],
|
489
|
+
:aws_host => creds[:aws_host]
|
490
|
+
)
|
491
|
+
role_info = sts.assume_role(
|
492
|
+
creds[:aws_sts_role_arn],
|
493
|
+
:session_name => creds[:aws_sts_role_session_name],
|
494
|
+
:external_id => creds[:aws_sts_external_id]
|
495
|
+
)
|
496
|
+
creds.merge!(role_info)
|
497
|
+
end
|
480
498
|
true
|
481
499
|
end
|
482
500
|
|
@@ -611,6 +629,7 @@ module Miasma
|
|
611
629
|
end
|
612
630
|
end
|
613
631
|
if(aws_sts_token)
|
632
|
+
sts_assume_role!(data) if sts_update_required?
|
614
633
|
options.set(:headers, 'X-Amz-Security-Token', aws_sts_token)
|
615
634
|
end
|
616
635
|
signature = signer.generate(http_method, path, options)
|
@@ -619,6 +638,12 @@ module Miasma
|
|
619
638
|
connection.auth(signature).send(http_method, dest, options)
|
620
639
|
end
|
621
640
|
|
641
|
+
# @return [TrueClass, FalseClass]
|
642
|
+
def sts_update_required?(args={})
|
643
|
+
expiry = args.fetch(:aws_sts_token_expires, data[:aws_sts_token_expires])
|
644
|
+
expiry.nil? || expiry >= Time.now - 1
|
645
|
+
end
|
646
|
+
|
622
647
|
# Simple callback to allow request option adjustments prior to
|
623
648
|
# signature calculation
|
624
649
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miasma-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: miasma
|
@@ -134,9 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.4.8
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Smoggy AWS API
|
141
141
|
test_files: []
|
142
|
-
has_rdoc:
|