MovableInkAWS 2.8.0 → 2.8.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: f349ad96411750bb34591fdab29321576d2d253571311ac28b17945befe0da25
4
- data.tar.gz: 1dfddfb2d024bf894a6b769115e57116a711458788da44920f15c1a75a9c0d55
3
+ metadata.gz: ae345b3fe4acd6f3054463c70369adfed8b3c5afa9f5875329585cb52b35087d
4
+ data.tar.gz: 5c6db268b0ef31eb56add0010eeacffa4e8d1425c10728a81ba01a92b90098a2
5
5
  SHA512:
6
- metadata.gz: 65af34acc71341c2c30f7e05cfc43c8712cc92b659f3505dbf520904524da80ccbd17e0e6e2430ee40fc406d25c200a9f3ca8088733bccbee0692a1cc11b83b5
7
- data.tar.gz: f4f630f2920477c57af48c5613207e646c0d870029ee72663250fdc95dbe108d652f9786b2af97940c087195c1611aab11f10ccf5a5a158d5d2931cc6219600c
6
+ metadata.gz: 8e2253d2636f7075d9ba9dcbc5237bba87def5d6865ff4db45149b94ab5e551d86abbbe5ffe7ff6059efa8798a2999af0bb9b5692db45302cbe73f895a34b562
7
+ data.tar.gz: 51c3f1882e637eb36e1806924123acfab8d8f07f0ccfaa66c560aea523bc13bca17eb0a8e798a48155660c645ad2b9d09434f58a8f5b662ab75e812f206d033b
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.1)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -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.1'
4
4
  end
5
5
  end
data/spec/ec2_spec.rb CHANGED
@@ -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.1
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-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core