MovableInkAWS 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -2
- data/lib/movable_ink/aws/ec2.rb +7 -6
- data/lib/movable_ink/version.rb +1 -1
- data/spec/ec2_spec.rb +11 -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: 1563396dc437243706adf250a3ab303f3e089c20d37b96f2e46e84389a099513
|
4
|
+
data.tar.gz: f59d9ad7bbea43ac3b2b18b1bf2fc6524aa0088bdfbe97e673dcfdb2bb548676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa44c9970ef0d0522c38c4af1824545f812ea0c2d5f796ae43d328539afe4e4a2ecdc3074925d6a68637a19c9162e600b9b2896e8812a806e0ef85e9f96d515a
|
7
|
+
data.tar.gz: 2f54162fa8a88a9293cacd11281d999e9f36e885f34389fe90349de5ddb173d4ff6f052e3f940878d98eb30a62c0f469ca54339908b0583555ae4c530262ffcf
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
MovableInkAWS (0.
|
4
|
+
MovableInkAWS (0.5.0)
|
5
5
|
aws-sdk (= 2.11.240)
|
6
|
+
aws-sigv4 (~> 1.1)
|
7
|
+
httparty (= 0.16.3)
|
6
8
|
|
7
9
|
GEM
|
8
10
|
remote: https://rubygems.org/
|
@@ -18,7 +20,14 @@ GEM
|
|
18
20
|
aws-sigv4 (1.1.0)
|
19
21
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
20
22
|
diff-lcs (1.3)
|
23
|
+
httparty (0.16.3)
|
24
|
+
mime-types (~> 3.0)
|
25
|
+
multi_xml (>= 0.5.2)
|
21
26
|
jmespath (1.4.0)
|
27
|
+
mime-types (3.2.2)
|
28
|
+
mime-types-data (~> 3.2015)
|
29
|
+
mime-types-data (3.2019.0331)
|
30
|
+
multi_xml (0.6.0)
|
22
31
|
rspec (3.6.0)
|
23
32
|
rspec-core (~> 3.6.0)
|
24
33
|
rspec-expectations (~> 3.6.0)
|
@@ -41,4 +50,4 @@ DEPENDENCIES
|
|
41
50
|
rspec (~> 3.6)
|
42
51
|
|
43
52
|
BUNDLED WITH
|
44
|
-
1.
|
53
|
+
1.17.1
|
data/lib/movable_ink/aws/ec2.rb
CHANGED
@@ -91,14 +91,15 @@ module MovableInk
|
|
91
91
|
@me ||= all_instances.select{|instance| instance.instance_id == instance_id}
|
92
92
|
end
|
93
93
|
|
94
|
-
def instances(role:, region: my_region, availability_zone: nil, exact_match: false)
|
94
|
+
def instances(role:, exclude_roles: [], region: my_region, availability_zone: nil, exact_match: false)
|
95
95
|
instances = all_instances(region: region).select { |instance|
|
96
96
|
instance.tags.select{ |tag| tag.key == 'mi:roles' }.detect { |tag|
|
97
97
|
roles = tag.value.split(/\s*,\s*/)
|
98
98
|
if exact_match
|
99
99
|
roles == [role]
|
100
100
|
else
|
101
|
-
|
101
|
+
exclude_roles.push('decommissioned')
|
102
|
+
roles.include?(role) && !roles.any? { |role| exclude_roles.include?(role) }
|
102
103
|
end
|
103
104
|
}
|
104
105
|
}
|
@@ -124,12 +125,12 @@ module MovableInk
|
|
124
125
|
instances.map(&:private_ip_address)
|
125
126
|
end
|
126
127
|
|
127
|
-
def instance_ip_addresses_by_role(role:, region: my_region, availability_zone: nil, exact_match: false)
|
128
|
-
private_ip_addresses(instances(role: role, region: region, availability_zone: availability_zone, exact_match: exact_match))
|
128
|
+
def instance_ip_addresses_by_role(role:, exclude_roles: [], region: my_region, availability_zone: nil, exact_match: false)
|
129
|
+
private_ip_addresses(instances(role: role, exclude_roles: exclude_roles, region: region, availability_zone: availability_zone, exact_match: exact_match))
|
129
130
|
end
|
130
131
|
|
131
|
-
def instance_ip_addresses_by_role_ordered(role:, region: my_region, exact_match: false)
|
132
|
-
instances = instances(role: role, region: region, exact_match: exact_match)
|
132
|
+
def instance_ip_addresses_by_role_ordered(role:, exclude_roles: [], region: my_region, exact_match: false)
|
133
|
+
instances = instances(role: role, exclude_roles: exclude_roles, region: region, exact_match: exact_match)
|
133
134
|
instances_in_my_az = instances.select { |instance| instance.placement.availability_zone == availability_zone }
|
134
135
|
ordered_instances = instances_in_my_az.shuffle + (instances - instances_in_my_az).shuffle
|
135
136
|
private_ip_addresses(ordered_instances)
|
data/lib/movable_ink/version.rb
CHANGED
data/spec/ec2_spec.rb
CHANGED
@@ -250,6 +250,17 @@ describe MovableInk::AWS::EC2 do
|
|
250
250
|
instances = aws.instances(role: 'app_db_replica', exact_match: true)
|
251
251
|
expect(instances.map{|i| i.tags.first.value }).to eq(['instance4'])
|
252
252
|
end
|
253
|
+
|
254
|
+
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
|
+
instances = aws.instances(role: 'app_db_replica', exclude_roles: ['db'])
|
262
|
+
expect(instances.map{|i| i.tags.first.value }).to eq(['instance1', 'instance4'])
|
263
|
+
end
|
253
264
|
end
|
254
265
|
|
255
266
|
context "ordered roles" do
|
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: 0.
|
4
|
+
version: 0.5.0
|
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
|
+
date: 2019-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|