miasma-aws 0.1.22 → 0.1.24
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/api/sts.rb +1 -4
- data/lib/miasma-aws/version.rb +1 -1
- data/lib/miasma/contrib/aws.rb +36 -16
- data/lib/miasma/contrib/aws/auto_scale.rb +2 -1
- data/lib/miasma/contrib/aws/compute.rb +13 -4
- data/lib/miasma/contrib/aws/load_balancer.rb +10 -5
- data/lib/miasma/contrib/aws/orchestration.rb +12 -10
- data/lib/miasma/contrib/aws/storage.rb +1 -1
- data/miasma-aws.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d85deafb276b73b989ef3d36568de4b167c9b66
|
4
|
+
data.tar.gz: b5e8c03917f79eab1054abc8d6f60d87336659ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61c9b43c6f169e567f42f63e2fff72f158976e71bbbe89eab08029129c142360b7a27c6dd92060eccfa3141119f3d84cf2a93bda2d0ef896b7de28d92505e42c
|
7
|
+
data.tar.gz: b1c62ce90ebeff0cd4770ba20cf26bfa521f6f2e5bc72a91ffcddf0bbe43da1abbc4c52964f91de3ecc92e20572b0280ac2d93fc055ccaa13db3b07022418461
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# v0.1.24
|
2
|
+
* Fix token usage causing request errors
|
3
|
+
* Tune retry behavior to isolate valid retry requests
|
4
|
+
* Properly pass external ID and session name through for STS
|
5
|
+
|
1
6
|
# v0.1.22
|
2
7
|
* Fix instance profile credential auto loading
|
3
8
|
* Add support for region auto-detection when using instance profiles
|
data/lib/miasma-aws/api/sts.rb
CHANGED
@@ -25,10 +25,7 @@ module Miasma
|
|
25
25
|
req_params = Smash.new.tap do |params|
|
26
26
|
params['Action'] = 'AssumeRole'
|
27
27
|
params['RoleArn'] = role_arn
|
28
|
-
params['RoleSessionName'] = args.
|
29
|
-
:session_name,
|
30
|
-
SecureRandom.uuid.tr('-', '')
|
31
|
-
)
|
28
|
+
params['RoleSessionName'] = args[:session_name] || SecureRandom.uuid.tr('-', '')
|
32
29
|
params['ExternalId'] = args[:external_id] if args[:external_id]
|
33
30
|
end
|
34
31
|
result = request(
|
data/lib/miasma-aws/version.rb
CHANGED
data/lib/miasma/contrib/aws.rb
CHANGED
@@ -335,6 +335,7 @@ module Miasma
|
|
335
335
|
attribute :aws_sts_role_arn, String
|
336
336
|
attribute :aws_sts_external_id, String
|
337
337
|
attribute :aws_sts_role_session_name, String
|
338
|
+
attribute :aws_sts_region, String
|
338
339
|
attribute :aws_credentials_file, String, :required => true, :default => File.join(Dir.home, '.aws/credentials')
|
339
340
|
attribute :aws_config_file, String, :required => true, :default => File.join(Dir.home, '.aws/config')
|
340
341
|
attribute :aws_access_key_id, String, :required => true
|
@@ -470,7 +471,11 @@ module Miasma
|
|
470
471
|
:aws_profile_name => creds[:aws_profile_name],
|
471
472
|
:aws_host => creds[:aws_host]
|
472
473
|
)
|
473
|
-
role_info = sts.assume_role(
|
474
|
+
role_info = sts.assume_role(
|
475
|
+
creds[:aws_sts_role_arn],
|
476
|
+
:session_name => creds[:aws_sts_role_session_name],
|
477
|
+
:external_id => creds[:aws_sts_external_id]
|
478
|
+
)
|
474
479
|
creds.merge!(role_info)
|
475
480
|
true
|
476
481
|
end
|
@@ -591,12 +596,10 @@ module Miasma
|
|
591
596
|
dest, options = request_args
|
592
597
|
path = URI.parse(dest).path
|
593
598
|
options = options ? options.to_smash : Smash.new
|
599
|
+
options[:headers] = Smash[connection.default_headers.to_a].merge(options.fetch(:headers, Smash.new))
|
594
600
|
if(self.class::API_VERSION)
|
595
601
|
if(options[:form])
|
596
602
|
options.set(:form, 'Version', self.class::API_VERSION)
|
597
|
-
if(aws_sts_token)
|
598
|
-
options.set(:form, 'SecurityToken', aws_sts_token)
|
599
|
-
end
|
600
603
|
else
|
601
604
|
options[:params] = options.fetch(
|
602
605
|
:params, Smash.new
|
@@ -605,21 +608,13 @@ module Miasma
|
|
605
608
|
'Version' => self.class::API_VERSION
|
606
609
|
)
|
607
610
|
)
|
608
|
-
if(aws_sts_token)
|
609
|
-
options.set(:params, 'SecurityToken', aws_sts_token)
|
610
|
-
end
|
611
611
|
end
|
612
612
|
end
|
613
|
+
if(aws_sts_token)
|
614
|
+
options.set(:headers, 'X-Amz-Security-Token', aws_sts_token)
|
615
|
+
end
|
613
616
|
update_request(connection, options)
|
614
|
-
signature = signer.generate(
|
615
|
-
http_method, path, options.merge(
|
616
|
-
Smash.new(
|
617
|
-
:headers => Smash[
|
618
|
-
connection.default_headers.to_a
|
619
|
-
]
|
620
|
-
)
|
621
|
-
)
|
622
|
-
)
|
617
|
+
signature = signer.generate(http_method, path, options)
|
623
618
|
options = Hash[options.map{|k,v|[k.to_sym,v]}]
|
624
619
|
connection.auth(signature).send(http_method, dest, options)
|
625
620
|
end
|
@@ -633,6 +628,31 @@ module Miasma
|
|
633
628
|
true
|
634
629
|
end
|
635
630
|
|
631
|
+
# Determine if a retry is allowed based on exception
|
632
|
+
#
|
633
|
+
# @param exception [Exception]
|
634
|
+
# @return [TrueClass, FalseClass]
|
635
|
+
def perform_request_retry(exception)
|
636
|
+
if(exception.is_a?(Miasma::Error::ApiError))
|
637
|
+
if([400, 500, 503].include?(exception.response.code))
|
638
|
+
if(exception.response.code == 400)
|
639
|
+
exception.response.body.to_s.downcase.include?('throttl')
|
640
|
+
else
|
641
|
+
true
|
642
|
+
end
|
643
|
+
else
|
644
|
+
false
|
645
|
+
end
|
646
|
+
end
|
647
|
+
end
|
648
|
+
|
649
|
+
# Always allow retry
|
650
|
+
#
|
651
|
+
# @return [TrueClass]
|
652
|
+
def retryable_allowed?(*_)
|
653
|
+
true
|
654
|
+
end
|
655
|
+
|
636
656
|
end
|
637
657
|
|
638
658
|
end
|
@@ -51,8 +51,9 @@ module Miasma
|
|
51
51
|
end
|
52
52
|
result = all_result_pages(nil, :body, 'DescribeAutoScalingGroupsResponse', 'DescribeAutoScalingGroupsResult', 'AutoScalingGroups', 'member') do |options|
|
53
53
|
request(
|
54
|
+
:method => :post,
|
54
55
|
:path => '/',
|
55
|
-
:
|
56
|
+
:form => options.merge(params)
|
56
57
|
)
|
57
58
|
end.map do |grp|
|
58
59
|
(group || Group.new(self)).load_data(
|
@@ -28,8 +28,9 @@ module Miasma
|
|
28
28
|
# @todo catch bad lookup and clear model
|
29
29
|
def server_reload(server)
|
30
30
|
result = request(
|
31
|
+
:method => :post,
|
31
32
|
:path => '/',
|
32
|
-
:
|
33
|
+
:form => {
|
33
34
|
'Action' => 'DescribeInstances',
|
34
35
|
'InstanceId.1' => server.id
|
35
36
|
}
|
@@ -52,8 +53,9 @@ module Miasma
|
|
52
53
|
def server_destroy(server)
|
53
54
|
if(server.persisted?)
|
54
55
|
result = request(
|
56
|
+
:method => :post,
|
55
57
|
:path => '/',
|
56
|
-
:
|
58
|
+
:form => {
|
57
59
|
'Action' => 'TerminateInstances',
|
58
60
|
'InstanceId.1' => server.id
|
59
61
|
}
|
@@ -67,8 +69,9 @@ module Miasma
|
|
67
69
|
unless(server.persisted?)
|
68
70
|
server.load_data(server.attributes)
|
69
71
|
result = request(
|
72
|
+
:method => :post,
|
70
73
|
:path => '/',
|
71
|
-
:
|
74
|
+
:form => {
|
72
75
|
'Action' => 'RunInstances',
|
73
76
|
'ImageId' => server.image_id,
|
74
77
|
'InstanceType' => server.flavor_id,
|
@@ -86,7 +89,13 @@ module Miasma
|
|
86
89
|
# @todo need to add auto pagination helper (as common util)
|
87
90
|
def server_all
|
88
91
|
results = all_result_pages(nil, :body, 'DescribeInstancesResponse', 'reservationSet', 'item') do |options|
|
89
|
-
request(
|
92
|
+
request(
|
93
|
+
:method => :post,
|
94
|
+
:path => '/',
|
95
|
+
:form => options.merge(
|
96
|
+
'Action' => 'DescribeInstances'
|
97
|
+
)
|
98
|
+
)
|
90
99
|
end
|
91
100
|
results.map do |srv|
|
92
101
|
[srv[:instancesSet][:item]].flatten.compact.map do |srv|
|
@@ -38,8 +38,9 @@ module Miasma
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
result = request(
|
41
|
+
:method => :post,
|
41
42
|
:path => '/',
|
42
|
-
:
|
43
|
+
:form => params.merge(
|
43
44
|
Smash.new(
|
44
45
|
'Action' => 'CreateLoadBalancer'
|
45
46
|
)
|
@@ -107,15 +108,17 @@ module Miasma
|
|
107
108
|
end
|
108
109
|
result = all_result_pages(nil, :body, 'DescribeLoadBalancersResponse', 'DescribeLoadBalancersResult', 'LoadBalancerDescriptions', 'member') do |options|
|
109
110
|
request(
|
111
|
+
:method => :post,
|
110
112
|
:path => '/',
|
111
|
-
:
|
113
|
+
:form => options.merge(params)
|
112
114
|
)
|
113
115
|
end
|
114
116
|
if(balancer)
|
115
117
|
health_result = all_result_pages(nil, :body, 'DescribeInstanceHealthResponse', 'DescribeInstanceHealthResult', 'InstanceStates', 'member') do |options|
|
116
118
|
request(
|
119
|
+
:method => :post,
|
117
120
|
:path => '/',
|
118
|
-
:
|
121
|
+
:form => options.merge(
|
119
122
|
'LoadBalancerName' => balancer.id || balancer.name,
|
120
123
|
'Action' => 'DescribeInstanceHealth'
|
121
124
|
)
|
@@ -158,8 +161,9 @@ module Miasma
|
|
158
161
|
def balancer_destroy(balancer)
|
159
162
|
if(balancer.persisted?)
|
160
163
|
request(
|
164
|
+
:method => :post,
|
161
165
|
:path => '/',
|
162
|
-
:
|
166
|
+
:form => Smash.new(
|
163
167
|
'Action' => 'DeleteLoadBalancer',
|
164
168
|
'LoadBalancerName' => balancer.name
|
165
169
|
)
|
@@ -187,8 +191,9 @@ module Miasma
|
|
187
191
|
def availability_zones
|
188
192
|
memoize(:availability_zones) do
|
189
193
|
res = api_for(:compute).request(
|
194
|
+
:method => :post,
|
190
195
|
:path => '/',
|
191
|
-
:
|
196
|
+
:form => Smash.new(
|
192
197
|
'Action' => 'DescribeAvailabilityZones'
|
193
198
|
)
|
194
199
|
).fetch(:body, 'DescribeAvailabilityZonesResponse', 'availabilityZoneInfo', 'item', [])
|
@@ -64,17 +64,17 @@ module Miasma
|
|
64
64
|
d_params['StackName'] = stack.id
|
65
65
|
descriptions = all_result_pages(nil, :body, 'DescribeStacksResponse', 'DescribeStacksResult', 'Stacks', 'member') do |options|
|
66
66
|
request(
|
67
|
+
:method => :post,
|
67
68
|
:path => '/',
|
68
|
-
:
|
69
|
-
:method => :get
|
69
|
+
:form => options.merge(d_params)
|
70
70
|
)
|
71
71
|
end
|
72
72
|
else
|
73
73
|
lists = all_result_pages(nil, :body, 'ListStacksResponse', 'ListStacksResult', 'StackSummaries', 'member') do |options|
|
74
74
|
request(
|
75
|
+
:method => :post,
|
75
76
|
:path => '/',
|
76
|
-
:form => options.merge(l_params)
|
77
|
-
:method => :post
|
77
|
+
:form => options.merge(l_params)
|
78
78
|
)
|
79
79
|
end
|
80
80
|
descriptions = []
|
@@ -226,8 +226,9 @@ module Miasma
|
|
226
226
|
def stack_destroy(stack)
|
227
227
|
if(stack.persisted?)
|
228
228
|
request(
|
229
|
+
:method => :post,
|
229
230
|
:path => '/',
|
230
|
-
:
|
231
|
+
:form => Smash.new(
|
231
232
|
'Action' => 'DeleteStack',
|
232
233
|
'StackName' => stack.id
|
233
234
|
)
|
@@ -245,8 +246,9 @@ module Miasma
|
|
245
246
|
def stack_template_load(stack)
|
246
247
|
if(stack.persisted?)
|
247
248
|
result = request(
|
249
|
+
:method => :post,
|
248
250
|
:path => '/',
|
249
|
-
:
|
251
|
+
:form => Smash.new(
|
250
252
|
'Action' => 'GetTemplate',
|
251
253
|
'StackName' => stack.id
|
252
254
|
)
|
@@ -308,9 +310,9 @@ module Miasma
|
|
308
310
|
def resource_all(stack)
|
309
311
|
results = all_result_pages(nil, :body, 'DescribeStackResourcesResponse', 'DescribeStackResourcesResult', 'StackResources', 'member') do |options|
|
310
312
|
request(
|
313
|
+
:method => :post,
|
311
314
|
:path => '/',
|
312
|
-
:
|
313
|
-
:params => options.merge(
|
315
|
+
:form => options.merge(
|
314
316
|
Smash.new(
|
315
317
|
'Action' => 'DescribeStackResources',
|
316
318
|
'StackName' => stack.id
|
@@ -348,9 +350,9 @@ module Miasma
|
|
348
350
|
def event_all(stack, evt_id=nil)
|
349
351
|
results = all_result_pages(nil, :body, 'DescribeStackEventsResponse', 'DescribeStackEventsResult', 'StackEvents', 'member') do |options|
|
350
352
|
request(
|
353
|
+
:method => :post,
|
351
354
|
:path => '/',
|
352
|
-
:
|
353
|
-
:params => options.merge(
|
355
|
+
:form => options.merge(
|
354
356
|
'Action' => 'DescribeStackEvents',
|
355
357
|
'StackName' => stack.id
|
356
358
|
)
|
@@ -437,7 +437,7 @@ module Miasma
|
|
437
437
|
# happening (which implicitly forces :form) or :json is used
|
438
438
|
# it will not properly checksum. (but that's probably okay)
|
439
439
|
def update_request(con, opts)
|
440
|
-
|
440
|
+
opts[:headers]['x-amz-content-sha256'] = Digest::SHA256.
|
441
441
|
hexdigest(opts.fetch(:body, ''))
|
442
442
|
true
|
443
443
|
end
|
data/miasma-aws.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = 'Smoggy AWS API'
|
11
11
|
s.license = 'Apache 2.0'
|
12
12
|
s.require_path = 'lib'
|
13
|
-
s.add_development_dependency 'miasma', '>= 0.2.
|
13
|
+
s.add_development_dependency 'miasma', '>= 0.2.29'
|
14
14
|
s.add_development_dependency 'pry'
|
15
15
|
s.add_development_dependency 'minitest'
|
16
16
|
s.add_development_dependency 'vcr'
|
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.24
|
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-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: miasma
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.29
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.29
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,8 +134,9 @@ 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.2.2
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Smoggy AWS API
|
141
141
|
test_files: []
|
142
|
+
has_rdoc:
|