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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/movable_ink/aws/ec2.rb +18 -0
- data/lib/movable_ink/version.rb +1 -1
- data/spec/ec2_spec.rb +29 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae345b3fe4acd6f3054463c70369adfed8b3c5afa9f5875329585cb52b35087d
|
4
|
+
data.tar.gz: 5c6db268b0ef31eb56add0010eeacffa4e8d1425c10728a81ba01a92b90098a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2253d2636f7075d9ba9dcbc5237bba87def5d6865ff4db45149b94ab5e551d86abbbe5ffe7ff6059efa8798a2999af0bb9b5692db45302cbe73f895a34b562
|
7
|
+
data.tar.gz: 51c3f1882e637eb36e1806924123acfab8d8f07f0ccfaa66c560aea523bc13bca17eb0a8e798a48155660c645ad2b9d09434f58a8f5b662ab75e812f206d033b
|
data/Gemfile.lock
CHANGED
data/lib/movable_ink/aws/ec2.rb
CHANGED
@@ -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
|
data/lib/movable_ink/version.rb
CHANGED
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.
|
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-
|
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
|