MovableInkAWS 2.8.0 → 2.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f349ad96411750bb34591fdab29321576d2d253571311ac28b17945befe0da25
4
- data.tar.gz: 1dfddfb2d024bf894a6b769115e57116a711458788da44920f15c1a75a9c0d55
3
+ metadata.gz: bf52a28dc79926b9dd09f38da90e0845f64fd7db39387ec7d2d3df92a84cdf5f
4
+ data.tar.gz: '0897366b09d975cd88a2333259f75de784536e7bc2441803997e3351a2d60271'
5
5
  SHA512:
6
- metadata.gz: 65af34acc71341c2c30f7e05cfc43c8712cc92b659f3505dbf520904524da80ccbd17e0e6e2430ee40fc406d25c200a9f3ca8088733bccbee0692a1cc11b83b5
7
- data.tar.gz: f4f630f2920477c57af48c5613207e646c0d870029ee72663250fdc95dbe108d652f9786b2af97940c087195c1611aab11f10ccf5a5a158d5d2931cc6219600c
6
+ metadata.gz: 27fa94453efdd9f4fad175b8069d0b59f135cb63068d2d393e22d9d0fd60093c2db599aa61cea1d1d19c6bbc95cce8a54dd03a1e691857a5227ea0b0ce2904b0
7
+ data.tar.gz: dd1c9c8cf0732151fff6942872d36de84585ca40875aea92d8ad0d3b5fa69c4194e07757ad20fe090f952c2eeb37dba23b551b291b1640628c4b9f4a029b9370
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (2.8.0)
4
+ MovableInkAWS (2.8.2)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -16,7 +16,7 @@ PATH
16
16
  aws-sdk-sns (~> 1)
17
17
  aws-sdk-ssm (~> 1)
18
18
  aws-sigv4 (~> 1.1)
19
- diplomat (= 2.4.2)
19
+ diplomat (= 2.6.4)
20
20
  httparty (= 0.16.3)
21
21
 
22
22
  GEM
@@ -25,73 +25,74 @@ GEM
25
25
  addressable (2.8.0)
26
26
  public_suffix (>= 2.0.2, < 5.0)
27
27
  aws-eventstream (1.2.0)
28
- aws-partitions (1.605.0)
29
- aws-sdk-athena (1.54.0)
30
- aws-sdk-core (~> 3, >= 3.127.0)
28
+ aws-partitions (1.673.0)
29
+ aws-sdk-athena (1.59.0)
30
+ aws-sdk-core (~> 3, >= 3.165.0)
31
31
  aws-sigv4 (~> 1.1)
32
- aws-sdk-autoscaling (1.79.0)
33
- aws-sdk-core (~> 3, >= 3.127.0)
32
+ aws-sdk-autoscaling (1.83.0)
33
+ aws-sdk-core (~> 3, >= 3.165.0)
34
34
  aws-sigv4 (~> 1.1)
35
- aws-sdk-cloudwatch (1.64.0)
36
- aws-sdk-core (~> 3, >= 3.127.0)
35
+ aws-sdk-cloudwatch (1.69.0)
36
+ aws-sdk-core (~> 3, >= 3.165.0)
37
37
  aws-sigv4 (~> 1.1)
38
- aws-sdk-core (3.131.2)
38
+ aws-sdk-core (3.168.3)
39
39
  aws-eventstream (~> 1, >= 1.0.2)
40
- aws-partitions (~> 1, >= 1.525.0)
41
- aws-sigv4 (~> 1.1)
40
+ aws-partitions (~> 1, >= 1.651.0)
41
+ aws-sigv4 (~> 1.5)
42
42
  jmespath (~> 1, >= 1.6.1)
43
- aws-sdk-ec2 (1.321.0)
44
- aws-sdk-core (~> 3, >= 3.127.0)
43
+ aws-sdk-ec2 (1.354.0)
44
+ aws-sdk-core (~> 3, >= 3.165.0)
45
45
  aws-sigv4 (~> 1.1)
46
- aws-sdk-eks (1.75.0)
47
- aws-sdk-core (~> 3, >= 3.127.0)
46
+ aws-sdk-eks (1.81.0)
47
+ aws-sdk-core (~> 3, >= 3.165.0)
48
48
  aws-sigv4 (~> 1.1)
49
- aws-sdk-elasticache (1.78.0)
50
- aws-sdk-core (~> 3, >= 3.127.0)
49
+ aws-sdk-elasticache (1.82.0)
50
+ aws-sdk-core (~> 3, >= 3.165.0)
51
51
  aws-sigv4 (~> 1.1)
52
- aws-sdk-iam (1.69.0)
53
- aws-sdk-core (~> 3, >= 3.127.0)
52
+ aws-sdk-iam (1.73.0)
53
+ aws-sdk-core (~> 3, >= 3.165.0)
54
54
  aws-sigv4 (~> 1.1)
55
- aws-sdk-kms (1.57.0)
56
- aws-sdk-core (~> 3, >= 3.127.0)
55
+ aws-sdk-kms (1.61.0)
56
+ aws-sdk-core (~> 3, >= 3.165.0)
57
57
  aws-sigv4 (~> 1.1)
58
- aws-sdk-rds (1.148.0)
59
- aws-sdk-core (~> 3, >= 3.127.0)
58
+ aws-sdk-rds (1.163.0)
59
+ aws-sdk-core (~> 3, >= 3.165.0)
60
60
  aws-sigv4 (~> 1.1)
61
- aws-sdk-route53 (1.63.0)
62
- aws-sdk-core (~> 3, >= 3.127.0)
61
+ aws-sdk-route53 (1.69.0)
62
+ aws-sdk-core (~> 3, >= 3.165.0)
63
63
  aws-sigv4 (~> 1.1)
64
- aws-sdk-s3 (1.114.0)
65
- aws-sdk-core (~> 3, >= 3.127.0)
64
+ aws-sdk-s3 (1.117.2)
65
+ aws-sdk-core (~> 3, >= 3.165.0)
66
66
  aws-sdk-kms (~> 1)
67
67
  aws-sigv4 (~> 1.4)
68
- aws-sdk-sns (1.53.0)
69
- aws-sdk-core (~> 3, >= 3.127.0)
68
+ aws-sdk-sns (1.57.0)
69
+ aws-sdk-core (~> 3, >= 3.165.0)
70
70
  aws-sigv4 (~> 1.1)
71
- aws-sdk-ssm (1.137.0)
72
- aws-sdk-core (~> 3, >= 3.127.0)
71
+ aws-sdk-ssm (1.145.0)
72
+ aws-sdk-core (~> 3, >= 3.165.0)
73
73
  aws-sigv4 (~> 1.1)
74
- aws-sigv4 (1.5.0)
74
+ aws-sigv4 (1.5.2)
75
75
  aws-eventstream (~> 1, >= 1.0.2)
76
76
  crack (0.4.5)
77
77
  rexml
78
78
  deep_merge (1.2.2)
79
79
  diff-lcs (1.3)
80
- diplomat (2.4.2)
81
- deep_merge (~> 1.0, >= 1.0.1)
82
- faraday (>= 0.9, < 1.1.0)
83
- faraday (1.0.1)
84
- multipart-post (>= 1.2, < 3)
80
+ diplomat (2.6.4)
81
+ deep_merge (~> 1.2)
82
+ faraday (>= 0.9, < 3.0, != 2.0.0)
83
+ faraday (2.7.1)
84
+ faraday-net_http (>= 2.0, < 3.1)
85
+ ruby2_keywords (>= 0.0.4)
86
+ faraday-net_http (3.0.2)
85
87
  hashdiff (1.0.1)
86
88
  httparty (0.16.3)
87
89
  mime-types (~> 3.0)
88
90
  multi_xml (>= 0.5.2)
89
- jmespath (1.6.1)
91
+ jmespath (1.6.2)
90
92
  mime-types (3.4.1)
91
93
  mime-types-data (~> 3.2015)
92
94
  mime-types-data (3.2022.0105)
93
95
  multi_xml (0.6.0)
94
- multipart-post (2.2.3)
95
96
  public_suffix (4.0.7)
96
97
  rexml (3.2.5)
97
98
  rspec (3.9.0)
@@ -107,6 +108,7 @@ GEM
107
108
  diff-lcs (>= 1.2.0, < 2.0)
108
109
  rspec-support (~> 3.9.0)
109
110
  rspec-support (3.9.3)
111
+ ruby2_keywords (0.0.5)
110
112
  webmock (3.17.1)
111
113
  addressable (>= 2.8.0)
112
114
  crack (>= 0.3.2)
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_runtime_dependency 'aws-sdk-ssm', '~> 1'
25
25
  s.add_runtime_dependency 'aws-sigv4', '~> 1.1'
26
26
  s.add_runtime_dependency 'httparty', '0.16.3'
27
- s.add_runtime_dependency 'diplomat', '2.4.2'
27
+ s.add_runtime_dependency 'diplomat', '2.6.4'
28
28
 
29
29
  all_files = `git ls-files`.split("\n")
30
30
  test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -255,6 +255,24 @@ module MovableInk
255
255
  })
256
256
  end
257
257
  end
258
+
259
+ def elastic_ip_address_exist?(public_ip:)
260
+ expected_errors = [
261
+ MovableInk::AWS::Errors::ExpectedError.new(Aws::EC2::Errors::InvalidAddressNotFound, [/Address \'#{public_ip}\' not found./])
262
+ ]
263
+ begin
264
+ run_with_backoff(expected_errors: expected_errors) do
265
+ ec2.describe_addresses({
266
+ public_ips: [public_ip]
267
+ })
268
+ return true
269
+ end
270
+ rescue MovableInk::AWS::Errors::ServiceError, Aws::EC2::Errors::InvalidAddressNotFound
271
+ return false
272
+ end
273
+ # returns false if it ran out of API retries
274
+ return false
275
+ end
258
276
  end
259
277
  end
260
278
  end
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '2.8.0'
3
+ VERSION = '2.8.2'
4
4
  end
5
5
  end
data/spec/ec2_spec.rb CHANGED
@@ -440,12 +440,12 @@ describe MovableInk::AWS::EC2 do
440
440
  allow(miaws).to receive(:my_region).and_return('us-east-1')
441
441
 
442
442
  json = JSON.generate(consul_app_service_instances)
443
- stub_request(:get, "https://localhost:8501/v1/health/service/app?cached&dc=#{my_datacenter}&passing&stale").
443
+ stub_request(:get, "https://localhost:8501/v1/health/service/app?cached=true&dc=#{my_datacenter}&passing=true&stale=true").
444
444
  with(
445
445
  headers: {
446
446
  'Accept'=>'*/*',
447
447
  'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
448
- 'User-Agent'=>'Faraday v1.0.1'
448
+ 'User-Agent'=>'Faraday v2.7.1'
449
449
  }).
450
450
  to_return(status: 200, body: json, headers: {})
451
451
 
@@ -453,12 +453,12 @@ describe MovableInk::AWS::EC2 do
453
453
  expect(app_instances.map{|i| i.tags.first[:value]}).to eq(['app_instance1', 'app_instance2'])
454
454
 
455
455
  json = JSON.generate(consul_ojos_service_instances)
456
- stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached&dc=#{my_datacenter}&passing&stale").
456
+ stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached=true&dc=#{my_datacenter}&passing=true&stale=true").
457
457
  with(
458
458
  headers: {
459
459
  'Accept'=>'*/*',
460
460
  'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
461
- 'User-Agent'=>'Faraday v1.0.1'
461
+ 'User-Agent'=>'Faraday v2.7.1'
462
462
  }).
463
463
  to_return(status: 200, body: json, headers: {})
464
464
 
@@ -471,12 +471,12 @@ describe MovableInk::AWS::EC2 do
471
471
  allow(miaws).to receive(:my_region).and_return('us-east-1')
472
472
 
473
473
  json = JSON.generate(consul_ojos_service_instances)
474
- stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached&dc=#{my_datacenter}&node-meta=availability_zone:#{other_availability_zone}&passing&stale").
474
+ stub_request(:get, "https://localhost:8501/v1/health/service/ojos?cached=true&dc=#{my_datacenter}&node-meta=availability_zone:#{other_availability_zone}&passing=true&stale=true").
475
475
  with(
476
476
  headers: {
477
477
  'Accept'=>'*/*',
478
478
  'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
479
- 'User-Agent'=>'Faraday v1.0.1'
479
+ 'User-Agent'=>'Faraday v2.7.1'
480
480
  }).
481
481
  to_return(status: 200, body: json, headers: {})
482
482
 
@@ -490,12 +490,12 @@ describe MovableInk::AWS::EC2 do
490
490
  allow(miaws).to receive(:my_region).and_return('us-east-1')
491
491
 
492
492
  json = JSON.generate(consul_kubernetes_service_instances)
493
- stub_request(:get, "https://localhost:8501/v1/health/service/kubernetes-service-name?cached&dc=#{my_datacenter}&passing&stale")
493
+ stub_request(:get, "https://localhost:8501/v1/health/service/kubernetes-service-name?cached=true&dc=#{my_datacenter}&passing=true&stale=true")
494
494
  .with({
495
495
  headers: {
496
496
  'Accept'=>'*/*',
497
497
  'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
498
- 'User-Agent'=>'Faraday v1.0.1'
498
+ 'User-Agent'=>'Faraday v2.7.1'
499
499
  }
500
500
  })
501
501
  .to_return(status: 200, body: json, headers: {})
@@ -718,5 +718,34 @@ describe MovableInk::AWS::EC2 do
718
718
  expect(aws.assign_ip_address(role: 'some_role').association_id).to eq('eipassoc-3')
719
719
  end
720
720
  end
721
+
722
+ context 'elastic ips' do
723
+ let(:public_ip_data) {ec2.stub_data(:describe_addresses, addresses: [
724
+ {
725
+ allocation_id: "eipalloc-12345678",
726
+ association_id: "eipassoc-12345678",
727
+ public_ip: "185.35.4.3",
728
+ }
729
+ ])
730
+ }
731
+
732
+ let(:empty_public_ip_data) {ec2.stub_data(:describe_addresses, addresses: [])}
733
+
734
+ it 'will return true when there is an elastic IP' do
735
+ ec2.stub_responses(:describe_addresses, public_ip_data)
736
+ allow(aws).to receive(:my_region).and_return('us-east-2')
737
+ allow(aws).to receive(:public_ip).and_return('185.35.3.4')
738
+ allow(aws).to receive(:ec2).and_return(ec2)
739
+ expect(aws.elastic_ip_address_exist?(public_ip: '185.35.3.4')).to eq(true)
740
+ end
741
+
742
+ it 'will return false when there is no elastic IP' do
743
+ ec2.stub_responses(:describe_addresses, MovableInk::AWS::Errors::ServiceError.new("Aws::EC2::Errors::InvalidAddressNotFound: Address \'185.35.3.4\' not found."))
744
+ allow(aws).to receive(:my_region).and_return('us-east-2')
745
+ allow(aws).to receive(:public_ip).and_return('185.35.3.4')
746
+ allow(aws).to receive(:ec2).and_return(ec2)
747
+ expect(aws.elastic_ip_address_exist?(public_ip: '185.35.3.4')).to eq(false)
748
+ end
749
+ end
721
750
  end
722
751
  end
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.8.0
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MI SRE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-31 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - '='
228
228
  - !ruby/object:Gem::Version
229
- version: 2.4.2
229
+ version: 2.6.4
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - '='
235
235
  - !ruby/object:Gem::Version
236
- version: 2.4.2
236
+ version: 2.6.4
237
237
  description: AWS Utility methods for MovableInk
238
238
  email: devops@movableink.com
239
239
  executables: []