MovableInkAWS 1.3.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +48 -28
- data/MovableInkAWS.gemspec +1 -0
- data/lib/movable_ink/aws.rb +1 -0
- data/lib/movable_ink/aws/ec2.rb +61 -1
- data/lib/movable_ink/aws/errors.rb +3 -0
- data/lib/movable_ink/aws/sns.rb +7 -16
- data/lib/movable_ink/version.rb +1 -1
- data/spec/ec2_spec.rb +146 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9748092eb913e843641b0ac9d68106cb8ae3dc141c5f3ef0cf2794c7b52a41f5
|
4
|
+
data.tar.gz: 1bcbc2de4d41898654cf8df5e09fb1a43465d338f73b64a36fcf785db882fb15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed19423e404a705e9caf74762f6bd1cd08b5f552af5b24d6c355364d59c422d2cfba5f225e10cd021a79e77ae5d65ee8773c86eda5340e32d69d088cfb4789c4
|
7
|
+
data.tar.gz: 6c5edc3a00e2d798140c30d2cce8279c03099e9b30aa1c1630e14a10ae075756328d9327ebfab94171bea47394503d4f9a592c9a8d5e706be37fe6c1dfbbd7f6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
MovableInkAWS (
|
4
|
+
MovableInkAWS (2.0.1)
|
5
5
|
aws-sdk-athena (~> 1)
|
6
6
|
aws-sdk-autoscaling (~> 1)
|
7
7
|
aws-sdk-cloudwatch (~> 1)
|
@@ -15,66 +15,80 @@ PATH
|
|
15
15
|
aws-sdk-sns (~> 1)
|
16
16
|
aws-sdk-ssm (~> 1)
|
17
17
|
aws-sigv4 (~> 1.1)
|
18
|
+
diplomat (= 2.4.2)
|
18
19
|
httparty (= 0.16.3)
|
19
20
|
|
20
21
|
GEM
|
21
22
|
remote: https://rubygems.org/
|
22
23
|
specs:
|
24
|
+
addressable (2.7.0)
|
25
|
+
public_suffix (>= 2.0.2, < 5.0)
|
23
26
|
aws-eventstream (1.1.0)
|
24
|
-
aws-partitions (1.
|
25
|
-
aws-sdk-athena (1.
|
26
|
-
aws-sdk-core (~> 3, >= 3.
|
27
|
+
aws-partitions (1.390.0)
|
28
|
+
aws-sdk-athena (1.33.0)
|
29
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
27
30
|
aws-sigv4 (~> 1.1)
|
28
|
-
aws-sdk-autoscaling (1.
|
29
|
-
aws-sdk-core (~> 3, >= 3.
|
31
|
+
aws-sdk-autoscaling (1.48.0)
|
32
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
30
33
|
aws-sigv4 (~> 1.1)
|
31
|
-
aws-sdk-cloudwatch (1.
|
32
|
-
aws-sdk-core (~> 3, >= 3.
|
34
|
+
aws-sdk-cloudwatch (1.46.0)
|
35
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
33
36
|
aws-sigv4 (~> 1.1)
|
34
|
-
aws-sdk-core (3.
|
37
|
+
aws-sdk-core (3.109.2)
|
35
38
|
aws-eventstream (~> 1, >= 1.0.2)
|
36
39
|
aws-partitions (~> 1, >= 1.239.0)
|
37
40
|
aws-sigv4 (~> 1.1)
|
38
41
|
jmespath (~> 1.0)
|
39
|
-
aws-sdk-ec2 (1.
|
40
|
-
aws-sdk-core (~> 3, >= 3.
|
42
|
+
aws-sdk-ec2 (1.207.0)
|
43
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
41
44
|
aws-sigv4 (~> 1.1)
|
42
|
-
aws-sdk-eks (1.
|
43
|
-
aws-sdk-core (~> 3, >= 3.
|
45
|
+
aws-sdk-eks (1.45.0)
|
46
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
44
47
|
aws-sigv4 (~> 1.1)
|
45
|
-
aws-sdk-elasticache (1.
|
46
|
-
aws-sdk-core (~> 3, >= 3.
|
48
|
+
aws-sdk-elasticache (1.45.0)
|
49
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
47
50
|
aws-sigv4 (~> 1.1)
|
48
|
-
aws-sdk-kms (1.
|
49
|
-
aws-sdk-core (~> 3, >= 3.
|
51
|
+
aws-sdk-kms (1.39.0)
|
52
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
50
53
|
aws-sigv4 (~> 1.1)
|
51
|
-
aws-sdk-rds (1.
|
52
|
-
aws-sdk-core (~> 3, >= 3.
|
54
|
+
aws-sdk-rds (1.105.0)
|
55
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
53
56
|
aws-sigv4 (~> 1.1)
|
54
|
-
aws-sdk-route53 (1.
|
55
|
-
aws-sdk-core (~> 3, >= 3.
|
57
|
+
aws-sdk-route53 (1.44.0)
|
58
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
56
59
|
aws-sigv4 (~> 1.1)
|
57
|
-
aws-sdk-s3 (1.
|
58
|
-
aws-sdk-core (~> 3, >= 3.
|
60
|
+
aws-sdk-s3 (1.83.1)
|
61
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
59
62
|
aws-sdk-kms (~> 1)
|
60
63
|
aws-sigv4 (~> 1.1)
|
61
|
-
aws-sdk-sns (1.
|
62
|
-
aws-sdk-core (~> 3, >= 3.
|
64
|
+
aws-sdk-sns (1.35.0)
|
65
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
63
66
|
aws-sigv4 (~> 1.1)
|
64
|
-
aws-sdk-ssm (1.
|
65
|
-
aws-sdk-core (~> 3, >= 3.
|
67
|
+
aws-sdk-ssm (1.95.0)
|
68
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
66
69
|
aws-sigv4 (~> 1.1)
|
67
70
|
aws-sigv4 (1.2.2)
|
68
71
|
aws-eventstream (~> 1, >= 1.0.2)
|
72
|
+
crack (0.4.3)
|
73
|
+
safe_yaml (~> 1.0.0)
|
74
|
+
deep_merge (1.2.1)
|
69
75
|
diff-lcs (1.3)
|
76
|
+
diplomat (2.4.2)
|
77
|
+
deep_merge (~> 1.0, >= 1.0.1)
|
78
|
+
faraday (>= 0.9, < 1.1.0)
|
79
|
+
faraday (1.0.1)
|
80
|
+
multipart-post (>= 1.2, < 3)
|
81
|
+
hashdiff (1.0.0)
|
70
82
|
httparty (0.16.3)
|
71
83
|
mime-types (~> 3.0)
|
72
84
|
multi_xml (>= 0.5.2)
|
73
85
|
jmespath (1.4.0)
|
74
86
|
mime-types (3.3.1)
|
75
87
|
mime-types-data (~> 3.2015)
|
76
|
-
mime-types-data (3.2020.
|
88
|
+
mime-types-data (3.2020.1104)
|
77
89
|
multi_xml (0.6.0)
|
90
|
+
multipart-post (2.1.1)
|
91
|
+
public_suffix (4.0.5)
|
78
92
|
rspec (3.9.0)
|
79
93
|
rspec-core (~> 3.9.0)
|
80
94
|
rspec-expectations (~> 3.9.0)
|
@@ -88,6 +102,11 @@ GEM
|
|
88
102
|
diff-lcs (>= 1.2.0, < 2.0)
|
89
103
|
rspec-support (~> 3.9.0)
|
90
104
|
rspec-support (3.9.3)
|
105
|
+
safe_yaml (1.0.5)
|
106
|
+
webmock (3.7.6)
|
107
|
+
addressable (>= 2.3.6)
|
108
|
+
crack (>= 0.3.2)
|
109
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
91
110
|
|
92
111
|
PLATFORMS
|
93
112
|
ruby
|
@@ -95,6 +114,7 @@ PLATFORMS
|
|
95
114
|
DEPENDENCIES
|
96
115
|
MovableInkAWS!
|
97
116
|
rspec (~> 3.6)
|
117
|
+
webmock
|
98
118
|
|
99
119
|
BUNDLED WITH
|
100
120
|
2.1.3
|
data/MovableInkAWS.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency 'aws-sdk-ssm', '~> 1'
|
24
24
|
s.add_runtime_dependency 'aws-sigv4', '~> 1.1'
|
25
25
|
s.add_runtime_dependency 'httparty', '0.16.3'
|
26
|
+
s.add_runtime_dependency 'diplomat', '2.4.2'
|
26
27
|
|
27
28
|
all_files = `git ls-files`.split("\n")
|
28
29
|
test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/movable_ink/aws.rb
CHANGED
@@ -66,6 +66,7 @@ module MovableInk
|
|
66
66
|
Aws::EC2::Errors::Unavailable,
|
67
67
|
Aws::EKS::Errors::TooManyRequestsException,
|
68
68
|
Aws::SNS::Errors::ThrottledException,
|
69
|
+
Aws::SNS::Errors::Throttling,
|
69
70
|
Aws::AutoScaling::Errors::Throttling,
|
70
71
|
Aws::AutoScaling::Errors::ThrottledException,
|
71
72
|
Aws::S3::Errors::SlowDown,
|
data/lib/movable_ink/aws/ec2.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'aws-sdk-ec2'
|
2
|
+
require 'diplomat'
|
2
3
|
|
3
4
|
module MovableInk
|
4
5
|
class AWS
|
@@ -75,7 +76,7 @@ module MovableInk
|
|
75
76
|
@me ||= all_instances.select{|instance| instance.instance_id == instance_id}.first rescue nil
|
76
77
|
end
|
77
78
|
|
78
|
-
def
|
79
|
+
def instances_with_ec2_discovery(role:, exclude_roles: [], region: my_region, availability_zone: nil, exact_match: false, use_cache: true)
|
79
80
|
roles = role.split(/\s*,\s*/)
|
80
81
|
if use_cache == false
|
81
82
|
filter = default_filter.push({
|
@@ -106,6 +107,65 @@ module MovableInk
|
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
110
|
+
def instances_with_consul_discovery(role:, region: my_region, availability_zone: nil)
|
111
|
+
if role == nil || role == ''
|
112
|
+
raise MovableInk::AWS::Errors::RoleNameRequiredError
|
113
|
+
end
|
114
|
+
|
115
|
+
if role.include?('_')
|
116
|
+
raise MovableInk::AWS::Errors::RoleNameInvalidError
|
117
|
+
end
|
118
|
+
|
119
|
+
Diplomat.configure do |config|
|
120
|
+
config.url = "https://localhost:8501"
|
121
|
+
config.options = { ssl: { verify: false } }
|
122
|
+
end
|
123
|
+
|
124
|
+
consul_service_options = Hash.new
|
125
|
+
|
126
|
+
consul_service_options[:dc] = datacenter(region: region)
|
127
|
+
consul_service_options[:stale] = true
|
128
|
+
consul_service_options[:cached] = true
|
129
|
+
consul_service_options[:passing] = true
|
130
|
+
|
131
|
+
consul_service_options[:node_meta] = "availability_zone:#{availability_zone}" unless availability_zone.nil?
|
132
|
+
|
133
|
+
Diplomat::Health.service(role, consul_service_options).map { |endpoint|
|
134
|
+
OpenStruct.new (
|
135
|
+
{
|
136
|
+
private_ip_address: endpoint.Node['Address'],
|
137
|
+
instance_id: endpoint.Node['Meta']['instance_id'],
|
138
|
+
tags: [
|
139
|
+
{
|
140
|
+
key: 'Name',
|
141
|
+
value: endpoint.Node['Node']
|
142
|
+
},
|
143
|
+
{
|
144
|
+
key: 'mi:roles',
|
145
|
+
value: endpoint.Node['Meta']['mi_roles']
|
146
|
+
},
|
147
|
+
{
|
148
|
+
key: 'mi:monitoring_roles',
|
149
|
+
value: endpoint.Node['Meta']['mi_monitoring_roles']
|
150
|
+
}
|
151
|
+
],
|
152
|
+
placement: {
|
153
|
+
availability_zone: endpoint.Node['Meta']['availability_zone']
|
154
|
+
}
|
155
|
+
})
|
156
|
+
}
|
157
|
+
end
|
158
|
+
|
159
|
+
def instances(role:, exclude_roles: [], region: my_region, availability_zone: nil, exact_match: false, use_cache: true, discovery_type: 'ec2')
|
160
|
+
if discovery_type == 'ec2'
|
161
|
+
instances_with_ec2_discovery(role: role, exclude_roles: exclude_roles, region: region, availability_zone: availability_zone, exact_match: exact_match, use_cache: use_cache)
|
162
|
+
elsif discovery_type == 'consul'
|
163
|
+
instances_with_consul_discovery(role: role, region: region, availability_zone: availability_zone)
|
164
|
+
else
|
165
|
+
raise MovableInk::AWS::Errors::InvalidDiscoveryTypeError
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
109
169
|
def thopter
|
110
170
|
private_ip_addresses(thopter_instance).first
|
111
171
|
end
|
@@ -5,6 +5,9 @@ module MovableInk
|
|
5
5
|
class FailedWithBackoff < StandardError; end
|
6
6
|
class EC2Required < StandardError; end
|
7
7
|
class NoEnvironmentTagError < StandardError; end
|
8
|
+
class InvalidDiscoveryTypeError < StandardError; end
|
9
|
+
class RoleNameRequiredError < StandardError; end
|
10
|
+
class RoleNameInvalidError < StandardError; end
|
8
11
|
end
|
9
12
|
end
|
10
13
|
end
|
data/lib/movable_ink/aws/sns.rb
CHANGED
@@ -11,29 +11,20 @@ module MovableInk
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def sns_slack_topic_arn
|
14
|
-
|
15
|
-
sns.list_topics.each do |resp|
|
16
|
-
resp.topics.each do |topic|
|
17
|
-
return topic.topic_arn if topic.topic_arn.include? "slack-aws-alerts"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
14
|
+
@sns_slack_topic_arn ||= sns_topics.detect { |topic| topic.topic_arn.include? "slack-aws-alerts" }.topic_arn rescue nil
|
21
15
|
end
|
22
16
|
|
23
17
|
def sns_pagerduty_topic_arn
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
18
|
+
@sns_pagerduty_topic_arn ||= sns_topics.detect { |topic| topic.topic_arn.include? "pagerduty-custom-alerts" }.topic_arn rescue nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def sns_topics
|
22
|
+
@sns_topics ||= run_with_backoff { sns.list_topics.flat_map(&:topics) }
|
31
23
|
end
|
32
24
|
|
33
25
|
def notify_and_sleep(seconds, error_class)
|
34
26
|
message = "Throttled by AWS. Sleeping #{seconds} seconds, (#{error_class})"
|
35
|
-
notify_slack(subject: 'API Throttled',
|
36
|
-
message: message)
|
27
|
+
notify_slack(subject: 'API Throttled', message: message)
|
37
28
|
puts message
|
38
29
|
sleep seconds
|
39
30
|
end
|
data/lib/movable_ink/version.rb
CHANGED
data/spec/ec2_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative '../lib/movable_ink/aws'
|
2
|
+
require 'webmock/rspec'
|
2
3
|
|
3
4
|
describe MovableInk::AWS::EC2 do
|
4
5
|
context "outside EC2" do
|
@@ -21,6 +22,7 @@ describe MovableInk::AWS::EC2 do
|
|
21
22
|
end
|
22
23
|
|
23
24
|
context "inside EC2" do
|
25
|
+
WebMock.allow_net_connect!
|
24
26
|
let(:aws) { MovableInk::AWS.new }
|
25
27
|
let(:ec2) { Aws::EC2::Client.new(stub_responses: true) }
|
26
28
|
let(:tag_data) { ec2.stub_data(:describe_tags, tags: [
|
@@ -305,6 +307,150 @@ describe MovableInk::AWS::EC2 do
|
|
305
307
|
end
|
306
308
|
end
|
307
309
|
|
310
|
+
context "instances with consul discovery" do
|
311
|
+
let(:my_availability_zone) { 'us-east-1a' }
|
312
|
+
let(:my_datacenter) { 'iad' }
|
313
|
+
let(:other_availability_zone) { 'us-east-1b' }
|
314
|
+
let(:consul_app_service_instances) {
|
315
|
+
[{
|
316
|
+
Node: {
|
317
|
+
Node: 'app_instance1',
|
318
|
+
Address: '10.0.0.1',
|
319
|
+
Datacenter: my_datacenter,
|
320
|
+
Meta: {
|
321
|
+
availability_zone: my_availability_zone,
|
322
|
+
instance_id: 'i-12345',
|
323
|
+
mi_monitoring_roles: 'app',
|
324
|
+
mi_roles: 'app'
|
325
|
+
},
|
326
|
+
ServiceID: 'app',
|
327
|
+
ServiceName: 'app',
|
328
|
+
ServiceTags: ['foo', 'bar'],
|
329
|
+
ServicePort: 80,
|
330
|
+
}
|
331
|
+
},
|
332
|
+
{
|
333
|
+
Node: {
|
334
|
+
Node: 'app_instance2',
|
335
|
+
Address: '10.0.0.2',
|
336
|
+
Datacenter: my_datacenter,
|
337
|
+
Meta: {
|
338
|
+
availability_zone: my_availability_zone,
|
339
|
+
instance_id: 'i-54321',
|
340
|
+
mi_monitoring_roles: 'app',
|
341
|
+
mi_roles: 'app'
|
342
|
+
},
|
343
|
+
ServiceID: 'app',
|
344
|
+
ServiceName: 'app',
|
345
|
+
ServiceTags: ['foo', 'bar'],
|
346
|
+
ServicePort: 80,
|
347
|
+
}
|
348
|
+
}]
|
349
|
+
}
|
350
|
+
|
351
|
+
let(:consul_ojos_service_instances) {
|
352
|
+
[
|
353
|
+
{
|
354
|
+
Node: {
|
355
|
+
Node: 'ojos_instance2',
|
356
|
+
Address: '10.0.0.4',
|
357
|
+
Datacenter: my_datacenter,
|
358
|
+
Meta: {
|
359
|
+
availability_zone: other_availability_zone,
|
360
|
+
instance_id: 'i-zyx987',
|
361
|
+
mi_monitoring_roles: 'ojos',
|
362
|
+
mi_roles: 'ojos'
|
363
|
+
},
|
364
|
+
ServiceID: 'ojos',
|
365
|
+
ServiceName: 'ojos',
|
366
|
+
ServiceTags: ['foo', 'bar'],
|
367
|
+
ServicePort: 2702,
|
368
|
+
},
|
369
|
+
},
|
370
|
+
{
|
371
|
+
Node: {
|
372
|
+
Node: 'ojos_instance3',
|
373
|
+
Address: '10.0.0.5',
|
374
|
+
Datacenter: my_datacenter,
|
375
|
+
Meta: {
|
376
|
+
availability_zone: other_availability_zone,
|
377
|
+
instance_id: 'i-987654',
|
378
|
+
mi_monitoring_roles: 'ojos',
|
379
|
+
mi_roles: 'ojos'
|
380
|
+
},
|
381
|
+
ServiceID: 'ojos',
|
382
|
+
ServiceName: 'ojos',
|
383
|
+
ServiceTags: ['foo', 'bar'],
|
384
|
+
ServicePort: 2702,
|
385
|
+
}
|
386
|
+
}]
|
387
|
+
}
|
388
|
+
|
389
|
+
before(:each) do
|
390
|
+
allow(aws).to receive(:mi_env).and_return('test')
|
391
|
+
allow(aws).to receive(:availability_zone).and_return(my_availability_zone)
|
392
|
+
allow(aws).to receive(:my_region).and_return('us-east-1')
|
393
|
+
allow(aws).to receive(:ec2).and_return(ec2)
|
394
|
+
end
|
395
|
+
|
396
|
+
it "returns an error if no role is defined" do
|
397
|
+
expect{ aws.instances(role: nil, discovery_type: 'consul') }.to raise_error(MovableInk::AWS::Errors::RoleNameRequiredError)
|
398
|
+
end
|
399
|
+
|
400
|
+
it "returns an error if an invalid role is passed" do
|
401
|
+
expect{ aws.instances(role: 'asset_proxy', discovery_type: 'consul') }.to raise_error(MovableInk::AWS::Errors::RoleNameInvalidError)
|
402
|
+
end
|
403
|
+
|
404
|
+
it "returns all instances matching a consul service" do
|
405
|
+
miaws = double(MovableInk::AWS)
|
406
|
+
allow(miaws).to receive(:my_region).and_return('us-east-1')
|
407
|
+
|
408
|
+
json = JSON.generate(consul_app_service_instances)
|
409
|
+
stub_request(:get, "https://localhost:8501/v1/health/service/app?cached&dc=#{my_datacenter}&passing&stale").
|
410
|
+
with(
|
411
|
+
headers: {
|
412
|
+
'Accept'=>'*/*',
|
413
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
414
|
+
'User-Agent'=>'Faraday v1.0.1'
|
415
|
+
}).
|
416
|
+
to_return(status: 200, body: json, headers: {})
|
417
|
+
|
418
|
+
app_instances = aws.instances(role: 'app', discovery_type: 'consul')
|
419
|
+
expect(app_instances.map{|i| i.tags.first[:value]}).to eq(['app_instance1', 'app_instance2'])
|
420
|
+
|
421
|
+
json = JSON.generate(consul_ojos_service_instances)
|
422
|
+
stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached&dc=#{my_datacenter}&passing&stale").
|
423
|
+
with(
|
424
|
+
headers: {
|
425
|
+
'Accept'=>'*/*',
|
426
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
427
|
+
'User-Agent'=>'Faraday v1.0.1'
|
428
|
+
}).
|
429
|
+
to_return(status: 200, body: json, headers: {})
|
430
|
+
|
431
|
+
ojos_instances = aws.instances(role: 'ojos', discovery_type: 'consul')
|
432
|
+
expect(ojos_instances.map{|i| i.tags.first[:value ]}).to eq(['ojos_instance2', 'ojos_instance3'])
|
433
|
+
end
|
434
|
+
|
435
|
+
it "returns all instances matching a consul service filtered by availability_zone" do
|
436
|
+
miaws = double(MovableInk::AWS)
|
437
|
+
allow(miaws).to receive(:my_region).and_return('us-east-1')
|
438
|
+
|
439
|
+
json = JSON.generate(consul_ojos_service_instances)
|
440
|
+
stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached&dc=#{my_datacenter}&node-meta=availability_zone:#{other_availability_zone}&passing&stale").
|
441
|
+
with(
|
442
|
+
headers: {
|
443
|
+
'Accept'=>'*/*',
|
444
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
445
|
+
'User-Agent'=>'Faraday v1.0.1'
|
446
|
+
}).
|
447
|
+
to_return(status: 200, body: json, headers: {})
|
448
|
+
|
449
|
+
ojos_instances = aws.instances(role: 'ojos', availability_zone: other_availability_zone, discovery_type: 'consul')
|
450
|
+
expect(ojos_instances.map{|i| i.tags.first[:value]}).to eq(['ojos_instance2', 'ojos_instance3'])
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
308
454
|
context "ordered roles" do
|
309
455
|
let(:my_availability_zone) { 'us-east-1a' }
|
310
456
|
let(:other_availability_zone) { 'us-east-1b' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MovableInkAWS
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Chesler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - '='
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: 0.16.3
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: diplomat
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 2.4.2
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - '='
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 2.4.2
|
209
223
|
description: AWS Utility methods for MovableInk
|
210
224
|
email: mchesler@movableink.com
|
211
225
|
executables: []
|