MovableInkAWS 1.0.4 → 1.0.6
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/Gemfile.lock +2 -2
- data/lib/movable_ink/aws/ec2.rb +4 -4
- data/lib/movable_ink/version.rb +1 -1
- data/spec/ec2_spec.rb +22 -17
- 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: fe536c901487ed0196cb22c0c03dc62850aeb11ae503b467cd0be73caeacff04
|
4
|
+
data.tar.gz: bdc29c62402c6199ffb2ae84064013ef894fca69f5bd91ea517bd78288e7fabb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccde77e086f1787390314059aa32b11836cefd854518481afbd09ce198da9258c60eb0ed91e075b87fc70bac1fcd9ecb77b0d649c1c1bf90ec9f108becabd9bc
|
7
|
+
data.tar.gz: 682c1979026eb42cdfaa570be510c855412797d1e0ff41e20f644a6486cb27d96488dc34f1c465dd02de0d815f33f4ccd35ef42bf4289b797f182116cb68ab4a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
MovableInkAWS (1.0.
|
4
|
+
MovableInkAWS (1.0.6)
|
5
5
|
aws-sdk-athena (~> 1)
|
6
6
|
aws-sdk-autoscaling (~> 1)
|
7
7
|
aws-sdk-core (~> 3)
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
remote: https://rubygems.org/
|
19
19
|
specs:
|
20
20
|
aws-eventstream (1.0.3)
|
21
|
-
aws-partitions (1.
|
21
|
+
aws-partitions (1.238.0)
|
22
22
|
aws-sdk-athena (1.21.0)
|
23
23
|
aws-sdk-core (~> 3, >= 3.71.0)
|
24
24
|
aws-sigv4 (~> 1.1)
|
data/lib/movable_ink/aws/ec2.rb
CHANGED
@@ -67,9 +67,9 @@ module MovableInk
|
|
67
67
|
|
68
68
|
def instance_id
|
69
69
|
@instance_id ||= begin
|
70
|
-
|
71
|
-
raise(MovableInk::AWS::Errors::EC2Required) if
|
72
|
-
|
70
|
+
id = `ec2metadata --instance-id 2>/dev/null`.chomp
|
71
|
+
raise(MovableInk::AWS::Errors::EC2Required) if id.empty?
|
72
|
+
id
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -90,7 +90,7 @@ module MovableInk
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def me
|
93
|
-
@me ||= all_instances.select{|instance| instance.instance_id == instance_id}
|
93
|
+
@me ||= all_instances.select{|instance| instance.instance_id == instance_id}.first rescue nil
|
94
94
|
end
|
95
95
|
|
96
96
|
def instances(role:, exclude_roles: [], region: my_region, availability_zone: nil, exact_match: false)
|
data/lib/movable_ink/version.rb
CHANGED
data/spec/ec2_spec.rb
CHANGED
@@ -19,6 +19,11 @@ describe MovableInk::AWS::EC2 do
|
|
19
19
|
aws = MovableInk::AWS.new(environment: 'test')
|
20
20
|
expect(aws.mi_env).to eq('test')
|
21
21
|
end
|
22
|
+
|
23
|
+
it "should not find a 'me'" do
|
24
|
+
aws = MovableInk::AWS.new
|
25
|
+
expect(aws.me).to eq(nil)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
context "inside EC2" do
|
@@ -170,6 +175,7 @@ describe MovableInk::AWS::EC2 do
|
|
170
175
|
value: 'app, app_db_replica'
|
171
176
|
}
|
172
177
|
],
|
178
|
+
instance_id: 'i-12345',
|
173
179
|
private_ip_address: '10.0.0.1',
|
174
180
|
placement: {
|
175
181
|
availability_zone: my_availability_zone
|
@@ -186,6 +192,7 @@ describe MovableInk::AWS::EC2 do
|
|
186
192
|
value: 'app_db_replica,db'
|
187
193
|
}
|
188
194
|
],
|
195
|
+
instance_id: 'i-54321',
|
189
196
|
private_ip_address: '10.0.0.2',
|
190
197
|
placement: {
|
191
198
|
availability_zone: other_availability_zone
|
@@ -202,6 +209,7 @@ describe MovableInk::AWS::EC2 do
|
|
202
209
|
value: 'app_db, db'
|
203
210
|
}
|
204
211
|
],
|
212
|
+
instance_id: 'i-123abc',
|
205
213
|
private_ip_address: '10.0.0.3',
|
206
214
|
placement: {
|
207
215
|
availability_zone: other_availability_zone
|
@@ -218,6 +226,7 @@ describe MovableInk::AWS::EC2 do
|
|
218
226
|
value: 'app_db_replica'
|
219
227
|
}
|
220
228
|
],
|
229
|
+
instance_id: 'i-zyx987',
|
221
230
|
private_ip_address: '10.0.0.4',
|
222
231
|
placement: {
|
223
232
|
availability_zone: other_availability_zone
|
@@ -226,38 +235,34 @@ describe MovableInk::AWS::EC2 do
|
|
226
235
|
]])
|
227
236
|
}
|
228
237
|
|
229
|
-
|
238
|
+
before(:each) do
|
230
239
|
ec2.stub_responses(:describe_instances, instance_data)
|
231
240
|
allow(aws).to receive(:mi_env).and_return('test')
|
232
241
|
allow(aws).to receive(:availability_zone).and_return(my_availability_zone)
|
233
242
|
allow(aws).to receive(:my_region).and_return('us-east-1')
|
234
243
|
allow(aws).to receive(:ec2).and_return(ec2)
|
244
|
+
end
|
235
245
|
|
236
|
-
|
237
|
-
|
246
|
+
it "finds me" do
|
247
|
+
allow(aws).to receive(:instance_id).and_return('i-12345')
|
238
248
|
|
239
|
-
|
240
|
-
expect(instances.map{|i| i.tags.first.value }).to eq(['instance2', 'instance3'])
|
249
|
+
expect(aws.me.instance_id).to eq('i-12345')
|
241
250
|
end
|
242
251
|
|
243
|
-
it "returns
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
252
|
+
it "returns all instances matching a role" do
|
253
|
+
app_db_replica_instances = aws.instances(role: 'app_db_replica')
|
254
|
+
expect(app_db_replica_instances.map{|i| i.tags.first.value }).to eq(['instance1', 'instance2', 'instance4'])
|
255
|
+
|
256
|
+
db_instances = aws.instances(role: 'db')
|
257
|
+
expect(db_instances.map{|i| i.tags.first.value }).to eq(['instance2', 'instance3'])
|
258
|
+
end
|
249
259
|
|
260
|
+
it "returns roles with exactly the specified role" do
|
250
261
|
instances = aws.instances(role: 'app_db_replica', exact_match: true)
|
251
262
|
expect(instances.map{|i| i.tags.first.value }).to eq(['instance4'])
|
252
263
|
end
|
253
264
|
|
254
265
|
it "excludes requested roles" do
|
255
|
-
ec2.stub_responses(:describe_instances, instance_data)
|
256
|
-
allow(aws).to receive(:mi_env).and_return('test')
|
257
|
-
allow(aws).to receive(:availability_zone).and_return(my_availability_zone)
|
258
|
-
allow(aws).to receive(:my_region).and_return('us-east-1')
|
259
|
-
allow(aws).to receive(:ec2).and_return(ec2)
|
260
|
-
|
261
266
|
instances = aws.instances(role: 'app_db_replica', exclude_roles: ['db'])
|
262
267
|
expect(instances.map{|i| i.tags.first.value }).to eq(['instance1', 'instance4'])
|
263
268
|
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: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Chesler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|