MovableInkAWS 1.0.4 → 1.0.6

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: d186d81b84022427ded3829a3fdbff164a3b683aaa9156d2eca326021961628d
4
- data.tar.gz: '09ab0a5e2e503c6e86b200d9113288c53b687e27346ee7da434833fe6b048ca6'
3
+ metadata.gz: fe536c901487ed0196cb22c0c03dc62850aeb11ae503b467cd0be73caeacff04
4
+ data.tar.gz: bdc29c62402c6199ffb2ae84064013ef894fca69f5bd91ea517bd78288e7fabb
5
5
  SHA512:
6
- metadata.gz: f55481a7fb36fe5305f5aff741a21455de3891bf882788af848fbd8c27bea203a720da9840eb7ff4477f2b8629d3828ae57ca172c4672b3fafa40fdce200df49
7
- data.tar.gz: f899220d2d7a0dd219b1f96f7b7efd68dbbc1ff59e330c0296b8d418315f67fcfa760726be6cb5bfc1a7bb536cbe7dc1dfaa81b97599847b52aeb417fd5227cd
6
+ metadata.gz: ccde77e086f1787390314059aa32b11836cefd854518481afbd09ce198da9258c60eb0ed91e075b87fc70bac1fcd9ecb77b0d649c1c1bf90ec9f108becabd9bc
7
+ data.tar.gz: 682c1979026eb42cdfaa570be510c855412797d1e0ff41e20f644a6486cb27d96488dc34f1c465dd02de0d815f33f4ccd35ef42bf4289b797f182116cb68ab4a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (1.0.4)
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.236.0)
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)
@@ -67,9 +67,9 @@ module MovableInk
67
67
 
68
68
  def instance_id
69
69
  @instance_id ||= begin
70
- az = `ec2metadata --instance-id 2>/dev/null`.chomp
71
- raise(MovableInk::AWS::Errors::EC2Required) if az.empty?
72
- az
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)
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '1.0.4'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
@@ -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
- it "returns all instances matching a role" do
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
- instances = aws.instances(role: 'app_db_replica')
237
- expect(instances.map{|i| i.tags.first.value }).to eq(['instance1', 'instance2', 'instance4'])
246
+ it "finds me" do
247
+ allow(aws).to receive(:instance_id).and_return('i-12345')
238
248
 
239
- instances = aws.instances(role: 'db')
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 roles with exactly the specified role" do
244
- ec2.stub_responses(:describe_instances, instance_data)
245
- allow(aws).to receive(:mi_env).and_return('test')
246
- allow(aws).to receive(:availability_zone).and_return(my_availability_zone)
247
- allow(aws).to receive(:my_region).and_return('us-east-1')
248
- allow(aws).to receive(:ec2).and_return(ec2)
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
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-08 00:00:00.000000000 Z
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