MovableInkAWS 0.3.3 → 0.3.4
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 -6
- data/lib/movable_ink/version.rb +1 -1
- data/spec/ec2_spec.rb +71 -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: ffffe0e3ef8632871ef9a8645fab2a8072c85d8817e54cde4a8d4770c753b7f0
|
4
|
+
data.tar.gz: d78f852f878caa5c95297b912abe05b34fe66e3fa9cc69d4954b7c917d6a4b3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c959b4ed5ca462caf9361beb0ec318850e7a9f5de62ae4677fcea556ed062d31be68cdf98cde6f73a2fb6cf9139c9707cf9fb7003a57ee2e6c9d3d43a1ff417c
|
7
|
+
data.tar.gz: 9d74aaee3fa45e84ae18fc7a2e837a494b866766feaf827f51dc0c782781ed1d3ce9b860492610d017a6d7c1fdda2a5e04137aba93afb0222098197b66fc424c
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
MovableInkAWS (0.3.
|
4
|
+
MovableInkAWS (0.3.3)
|
5
5
|
aws-sdk (= 2.11.240)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
aws-eventstream (1.0.
|
10
|
+
aws-eventstream (1.0.3)
|
11
11
|
aws-sdk (2.11.240)
|
12
12
|
aws-sdk-resources (= 2.11.240)
|
13
13
|
aws-sdk-core (2.11.240)
|
data/lib/movable_ink/aws/ec2.rb
CHANGED
@@ -94,15 +94,13 @@ module MovableInk
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def instances(role:, region: my_region, availability_zone: nil)
|
97
|
-
role_pattern = mi_env == 'production' ? "^#{role}$" : "^*#{role}*$"
|
98
|
-
role_pattern = role_pattern.gsub('**','*').gsub('*','.*')
|
99
97
|
instances = all_instances(region: region).select { |instance|
|
100
|
-
instance.tags.detect { |tag|
|
101
|
-
tag.
|
102
|
-
|
103
|
-
!tag.value.include?('decommissioned')
|
98
|
+
instance.tags.select{ |tag| tag.key == 'mi:roles' }.detect { |tag|
|
99
|
+
roles = tag.value.split(/\s*,\s*/)
|
100
|
+
roles.include?(role) && !roles.include?('decommissioned')
|
104
101
|
}
|
105
102
|
}
|
103
|
+
|
106
104
|
if availability_zone
|
107
105
|
instances.select { |instance|
|
108
106
|
instance.placement.availability_zone == availability_zone
|
data/lib/movable_ink/version.rb
CHANGED
data/spec/ec2_spec.rb
CHANGED
@@ -144,6 +144,77 @@ describe MovableInk::AWS::EC2 do
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
context "instances" do
|
148
|
+
let(:my_availability_zone) { 'us-east-1a' }
|
149
|
+
let(:other_availability_zone) { 'us-east-1b' }
|
150
|
+
let(:instance_data) { ec2.stub_data(:describe_instances, reservations: [
|
151
|
+
instances: [
|
152
|
+
{
|
153
|
+
tags: [
|
154
|
+
{
|
155
|
+
key: 'mi:name',
|
156
|
+
value: 'instance1'
|
157
|
+
},
|
158
|
+
{
|
159
|
+
key: 'mi:roles',
|
160
|
+
value: 'app, app_db_replica'
|
161
|
+
}
|
162
|
+
],
|
163
|
+
private_ip_address: '10.0.0.1',
|
164
|
+
placement: {
|
165
|
+
availability_zone: my_availability_zone
|
166
|
+
}
|
167
|
+
},
|
168
|
+
{
|
169
|
+
tags: [
|
170
|
+
{
|
171
|
+
key: 'mi:name',
|
172
|
+
value: 'instance2'
|
173
|
+
},
|
174
|
+
{
|
175
|
+
key: 'mi:roles',
|
176
|
+
value: 'app_db_replica,db'
|
177
|
+
}
|
178
|
+
],
|
179
|
+
private_ip_address: '10.0.0.2',
|
180
|
+
placement: {
|
181
|
+
availability_zone: other_availability_zone
|
182
|
+
}
|
183
|
+
},
|
184
|
+
{
|
185
|
+
tags: [
|
186
|
+
{
|
187
|
+
key: 'mi:name',
|
188
|
+
value: 'instance3'
|
189
|
+
},
|
190
|
+
{
|
191
|
+
key: 'mi:roles',
|
192
|
+
value: 'app_db, db'
|
193
|
+
}
|
194
|
+
],
|
195
|
+
private_ip_address: '10.0.0.2',
|
196
|
+
placement: {
|
197
|
+
availability_zone: other_availability_zone
|
198
|
+
}
|
199
|
+
}
|
200
|
+
]])
|
201
|
+
}
|
202
|
+
|
203
|
+
it "returns all instances matching a role" do
|
204
|
+
ec2.stub_responses(:describe_instances, instance_data)
|
205
|
+
allow(aws).to receive(:mi_env).and_return('test')
|
206
|
+
allow(aws).to receive(:availability_zone).and_return(my_availability_zone)
|
207
|
+
allow(aws).to receive(:my_region).and_return('us-east-1')
|
208
|
+
allow(aws).to receive(:ec2).and_return(ec2)
|
209
|
+
|
210
|
+
instances = aws.instances(role: 'app_db_replica')
|
211
|
+
expect(instances.map{|i| i.tags.first.value }).to eq(['instance1', 'instance2'])
|
212
|
+
|
213
|
+
instances = aws.instances(role: 'db')
|
214
|
+
expect(instances.map{|i| i.tags.first.value }).to eq(['instance2', 'instance3'])
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
147
218
|
context "ordered roles" do
|
148
219
|
let(:my_availability_zone) { 'us-east-1a' }
|
149
220
|
let(:other_availability_zone) { 'us-east-1b' }
|
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.3.
|
4
|
+
version: 0.3.4
|
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-06-
|
11
|
+
date: 2019-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|