MovableInkAWS 2.0.0 → 2.0.1

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: ca127d84b2a782fac6a45b9f2ab7d39891ea9b58c1f72897198363fdec217b03
4
- data.tar.gz: 1bead2930395e8a2f53b7dce303a5904790072e78f7abf965514f29af736d7ac
3
+ metadata.gz: 9748092eb913e843641b0ac9d68106cb8ae3dc141c5f3ef0cf2794c7b52a41f5
4
+ data.tar.gz: 1bcbc2de4d41898654cf8df5e09fb1a43465d338f73b64a36fcf785db882fb15
5
5
  SHA512:
6
- metadata.gz: 6225008398613de6fd9d239394029bf141252ed6adca815068bd1a88be2df8e7a6947a3a7055aaab41d4833c00edeb770e90b191395f139597fb7a5455de47c9
7
- data.tar.gz: 5bf8debaf1f7afafb249b494d26c5142c5d5ce147721e112183c5c6f66a5d7a543c1af7d5f4d3cf4fbe701763a50042c5ed47d6a288db357b0b364c51fbb3713
6
+ metadata.gz: ed19423e404a705e9caf74762f6bd1cd08b5f552af5b24d6c355364d59c422d2cfba5f225e10cd021a79e77ae5d65ee8773c86eda5340e32d69d088cfb4789c4
7
+ data.tar.gz: 6c5edc3a00e2d798140c30d2cce8279c03099e9b30aa1c1630e14a10ae075756328d9327ebfab94171bea47394503d4f9a592c9a8d5e706be37fe6c1dfbbd7f6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (1.3.3)
4
+ MovableInkAWS (2.0.1)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -24,34 +24,34 @@ GEM
24
24
  addressable (2.7.0)
25
25
  public_suffix (>= 2.0.2, < 5.0)
26
26
  aws-eventstream (1.1.0)
27
- aws-partitions (1.383.0)
27
+ aws-partitions (1.390.0)
28
28
  aws-sdk-athena (1.33.0)
29
29
  aws-sdk-core (~> 3, >= 3.109.0)
30
30
  aws-sigv4 (~> 1.1)
31
- aws-sdk-autoscaling (1.47.0)
31
+ aws-sdk-autoscaling (1.48.0)
32
32
  aws-sdk-core (~> 3, >= 3.109.0)
33
33
  aws-sigv4 (~> 1.1)
34
- aws-sdk-cloudwatch (1.45.0)
34
+ aws-sdk-cloudwatch (1.46.0)
35
35
  aws-sdk-core (~> 3, >= 3.109.0)
36
36
  aws-sigv4 (~> 1.1)
37
- aws-sdk-core (3.109.1)
37
+ aws-sdk-core (3.109.2)
38
38
  aws-eventstream (~> 1, >= 1.0.2)
39
39
  aws-partitions (~> 1, >= 1.239.0)
40
40
  aws-sigv4 (~> 1.1)
41
41
  jmespath (~> 1.0)
42
- aws-sdk-ec2 (1.200.0)
42
+ aws-sdk-ec2 (1.207.0)
43
43
  aws-sdk-core (~> 3, >= 3.109.0)
44
44
  aws-sigv4 (~> 1.1)
45
45
  aws-sdk-eks (1.45.0)
46
46
  aws-sdk-core (~> 3, >= 3.109.0)
47
47
  aws-sigv4 (~> 1.1)
48
- aws-sdk-elasticache (1.44.0)
48
+ aws-sdk-elasticache (1.45.0)
49
49
  aws-sdk-core (~> 3, >= 3.109.0)
50
50
  aws-sigv4 (~> 1.1)
51
51
  aws-sdk-kms (1.39.0)
52
52
  aws-sdk-core (~> 3, >= 3.109.0)
53
53
  aws-sigv4 (~> 1.1)
54
- aws-sdk-rds (1.104.0)
54
+ aws-sdk-rds (1.105.0)
55
55
  aws-sdk-core (~> 3, >= 3.109.0)
56
56
  aws-sigv4 (~> 1.1)
57
57
  aws-sdk-route53 (1.44.0)
@@ -61,7 +61,7 @@ GEM
61
61
  aws-sdk-core (~> 3, >= 3.109.0)
62
62
  aws-sdk-kms (~> 1)
63
63
  aws-sigv4 (~> 1.1)
64
- aws-sdk-sns (1.33.0)
64
+ aws-sdk-sns (1.35.0)
65
65
  aws-sdk-core (~> 3, >= 3.109.0)
66
66
  aws-sigv4 (~> 1.1)
67
67
  aws-sdk-ssm (1.95.0)
@@ -85,7 +85,7 @@ GEM
85
85
  jmespath (1.4.0)
86
86
  mime-types (3.3.1)
87
87
  mime-types-data (~> 3.2015)
88
- mime-types-data (3.2020.0512)
88
+ mime-types-data (3.2020.1104)
89
89
  multi_xml (0.6.0)
90
90
  multipart-post (2.1.1)
91
91
  public_suffix (4.0.5)
@@ -121,38 +121,39 @@ module MovableInk
121
121
  config.options = { ssl: { verify: false } }
122
122
  end
123
123
 
124
- consul_instances = Diplomat::Service.get(role, :all, { :dc => datacenter(region: region), :stale => true, :cached => true }).map { |node|
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|
125
134
  OpenStruct.new (
126
- {
127
- private_ip_address: node.Address,
128
- instance_id: node.NodeMeta['instance_id'],
135
+ {
136
+ private_ip_address: endpoint.Node['Address'],
137
+ instance_id: endpoint.Node['Meta']['instance_id'],
129
138
  tags: [
130
139
  {
131
140
  key: 'Name',
132
- value: node.Node
141
+ value: endpoint.Node['Node']
133
142
  },
134
143
  {
135
144
  key: 'mi:roles',
136
- value: node.NodeMeta['mi_roles']
145
+ value: endpoint.Node['Meta']['mi_roles']
137
146
  },
138
147
  {
139
148
  key: 'mi:monitoring_roles',
140
- value: node.NodeMeta['mi_monitoring_roles']
149
+ value: endpoint.Node['Meta']['mi_monitoring_roles']
141
150
  }
142
151
  ],
143
152
  placement: {
144
- availability_zone: node.NodeMeta['availability_zone']
153
+ availability_zone: endpoint.Node['Meta']['availability_zone']
145
154
  }
146
155
  })
147
156
  }
148
-
149
- if availability_zone
150
- consul_instances.select { |consul_instance|
151
- consul_instance.placement[:availability_zone] == availability_zone
152
- }
153
- else
154
- consul_instances
155
- end
156
157
  end
157
158
 
158
159
  def instances(role:, exclude_roles: [], region: my_region, availability_zone: nil, exact_match: false, use_cache: true, discovery_type: 'ec2')
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -312,93 +312,78 @@ describe MovableInk::AWS::EC2 do
312
312
  let(:my_datacenter) { 'iad' }
313
313
  let(:other_availability_zone) { 'us-east-1b' }
314
314
  let(:consul_app_service_instances) {
315
- [
316
- {
317
- Node: 'app_instance1',
318
- Address: '10.0.0.1',
319
- Datacenter: my_datacenter,
320
- NodeMeta:
321
- {
322
- availability_zone: my_availability_zone,
323
- instance_id: 'i-12345',
324
- mi_monitoring_roles: 'app',
325
- mi_roles: 'app'
326
- },
327
- ServiceID: 'app',
328
- ServiceName: 'app',
329
- ServiceTags: ['foo', 'bar'],
330
- ServicePort: 80,
331
- },
332
- {
333
- Node: 'app_instance2',
334
- Address: '10.0.0.2',
335
- Datacenter: my_datacenter,
336
- NodeMeta:
337
- {
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
- ]
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
349
  }
350
350
 
351
351
  let(:consul_ojos_service_instances) {
352
352
  [
353
- {
354
- Node: 'ojos_instance1',
355
- Address: '10.0.0.3',
356
- Datacenter: my_datacenter,
357
- NodeMeta:
358
- {
359
- availability_zone: my_availability_zone,
360
- instance_id: 'i-123abc',
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
- Node: 'ojos_instance2',
371
- Address: '10.0.0.4',
372
- Datacenter: my_datacenter,
373
- NodeMeta:
374
- {
375
- availability_zone: other_availability_zone,
376
- instance_id: 'i-zyx987',
377
- mi_monitoring_roles: 'ojos',
378
- mi_roles: 'ojos'
379
- },
380
- ServiceID: 'ojos',
381
- ServiceName: 'ojos',
382
- ServiceTags: ['foo', 'bar'],
383
- ServicePort: 2702,
384
- },
385
- {
386
- Node: 'ojos_instance3',
387
- Address: '10.0.0.5',
388
- Datacenter: my_datacenter,
389
- NodeMeta:
390
- {
391
- availability_zone: other_availability_zone,
392
- instance_id: 'i-987654',
393
- mi_monitoring_roles: 'ojos',
394
- mi_roles: 'ojos'
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,
395
368
  },
396
- ServiceID: 'ojos',
397
- ServiceName: 'ojos',
398
- ServiceTags: ['foo', 'bar'],
399
- ServicePort: 2702,
400
- }
401
- ]
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
+ }]
402
387
  }
403
388
 
404
389
  before(:each) do
@@ -421,7 +406,7 @@ describe MovableInk::AWS::EC2 do
421
406
  allow(miaws).to receive(:my_region).and_return('us-east-1')
422
407
 
423
408
  json = JSON.generate(consul_app_service_instances)
424
- stub_request(:get, "https://localhost:8501/v1/catalog/service/app?dc=#{my_datacenter}&stale=true&cached=true").
409
+ stub_request(:get, "https://localhost:8501/v1/health/service/app?cached&dc=#{my_datacenter}&passing&stale").
425
410
  with(
426
411
  headers: {
427
412
  'Accept'=>'*/*',
@@ -434,7 +419,7 @@ describe MovableInk::AWS::EC2 do
434
419
  expect(app_instances.map{|i| i.tags.first[:value]}).to eq(['app_instance1', 'app_instance2'])
435
420
 
436
421
  json = JSON.generate(consul_ojos_service_instances)
437
- stub_request(:get, "https://localhost:8501/v1/catalog/service/ojos?dc=#{my_datacenter}&stale=true&cached=true").
422
+ stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached&dc=#{my_datacenter}&passing&stale").
438
423
  with(
439
424
  headers: {
440
425
  'Accept'=>'*/*',
@@ -444,7 +429,7 @@ describe MovableInk::AWS::EC2 do
444
429
  to_return(status: 200, body: json, headers: {})
445
430
 
446
431
  ojos_instances = aws.instances(role: 'ojos', discovery_type: 'consul')
447
- expect(ojos_instances.map{|i| i.tags.first[:value ]}).to eq(['ojos_instance1', 'ojos_instance2', 'ojos_instance3'])
432
+ expect(ojos_instances.map{|i| i.tags.first[:value ]}).to eq(['ojos_instance2', 'ojos_instance3'])
448
433
  end
449
434
 
450
435
  it "returns all instances matching a consul service filtered by availability_zone" do
@@ -452,7 +437,7 @@ describe MovableInk::AWS::EC2 do
452
437
  allow(miaws).to receive(:my_region).and_return('us-east-1')
453
438
 
454
439
  json = JSON.generate(consul_ojos_service_instances)
455
- stub_request(:get, "https://localhost:8501/v1/catalog/service/ojos?dc=iad&stale=true&cached=true").
440
+ stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached&dc=#{my_datacenter}&node-meta=availability_zone:#{other_availability_zone}&passing&stale").
456
441
  with(
457
442
  headers: {
458
443
  'Accept'=>'*/*',
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: 2.0.0
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-04 00:00:00.000000000 Z
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