MovableInkAWS 0.3.2 → 0.3.3

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: be8b5cd511cee342df9b7f9855f352b7f07f66e6acf7fd13aac99316c4ce4316
4
- data.tar.gz: b803df59e02733a86769a5f10627347708891fd20763e69e294617f0222ec1fa
3
+ metadata.gz: 71c6b935514942f31b17b7c3bad0c8e0a856eb3586b977c20a6721ddd6623b8a
4
+ data.tar.gz: 63144d8ef0655a3df7a5f5768624f2500964a213529de972b286b16d63cc901e
5
5
  SHA512:
6
- metadata.gz: a52896926328ec012a46647f8f237d6eca2685fa082a16aa426f8129b3dcd88758a4333f8240cfe5208e4f4227e743649036920c385063ac1487fa7aa99acecd
7
- data.tar.gz: cd4a365c76df0ee1089ac933e30c1676da4e5787057afed8d4f328c45a17bcb8635581c07834664d9134b77ecef57893cb31186e0a79489552c34cb351500b6e
6
+ metadata.gz: 430fd3b181252e7c3bc538afd4a621ae8a0ec39e98b2329d03266ccbd06d787f91f2065ba9a68ce09b6b45e79cb8f275fec29e367f056d9296e7d0d1dd345ba9
7
+ data.tar.gz: 28e155f91856f6bc291aa253cc2c35aa259cf941c7290dda27fd917f8139bc0adbf4e45aa452057ebc817e4ae743a5a1ba10770b1496e6807e92d92655176b55
@@ -28,29 +28,23 @@ module MovableInk
28
28
  end
29
29
  end
30
30
 
31
- def thopter_instance
32
- @thopter_instance ||= load_thopter_instance
31
+ def thopter_filter
32
+ [{
33
+ name: 'tag:mi:roles',
34
+ values: ['*thopter*']
35
+ },
36
+ {
37
+ name: 'tag:mi:env',
38
+ values: [mi_env]
39
+ },
40
+ {
41
+ name: 'instance-state-name',
42
+ values: ['running']
43
+ }]
33
44
  end
34
45
 
35
- def load_thopter_instance
36
- run_with_backoff do
37
- ec2(region: 'us-east-1').describe_instances(filters: [
38
- {
39
- name: 'tag:mi:roles',
40
- values: ['*thopter*']
41
- },
42
- {
43
- name: 'tag:mi:env',
44
- values: [mi_env]
45
- },
46
- {
47
- name: 'instance-state-name',
48
- values: ['running']
49
- }
50
- ])
51
- .reservations
52
- .flat_map(&:instances)
53
- end
46
+ def thopter_instance
47
+ @thopter_instance ||= load_all_instances('us-east-1', filter: thopter_filter)
54
48
  end
55
49
 
56
50
  def all_instances(region: my_region, no_filter: false)
@@ -58,19 +52,20 @@ module MovableInk
58
52
  @all_instances[region] ||= load_all_instances(region, no_filter: no_filter)
59
53
  end
60
54
 
61
- def load_all_instances(region, no_filter: false)
62
- filters = if no_filter
63
- nil
64
- else
65
- [{
66
- name: 'instance-state-name',
67
- values: ['running']
68
- },
69
- {
70
- name: 'tag:mi:env',
71
- values: [mi_env]
72
- }]
73
- end
55
+ def default_filter
56
+ [{
57
+ name: 'instance-state-name',
58
+ values: ['running']
59
+ },
60
+ {
61
+ name: 'tag:mi:env',
62
+ values: [mi_env]
63
+ }]
64
+ end
65
+
66
+ def load_all_instances(region, no_filter: false, filter: nil)
67
+ filters = no_filter ? nil : (filter || default_filter)
68
+
74
69
  run_with_backoff do
75
70
  ec2(region: region).describe_instances(filters: filters).flat_map do |resp|
76
71
  resp.reservations.flat_map(&:instances)
@@ -34,6 +34,27 @@ module MovableInk
34
34
  }).flat_map(&:resource_record_sets)
35
35
  end
36
36
  end
37
+
38
+ def list_health_checks
39
+ run_with_backoff do
40
+ route53.list_health_checks().flat_map(&:health_checks)
41
+ end
42
+ end
43
+
44
+ def get_health_check_tags(health_check_id)
45
+ run_with_backoff do
46
+ route53.list_tags_for_resource({
47
+ resource_type: 'healthcheck',
48
+ resource_id: health_check_id
49
+ }).resource_tag_set.tags
50
+ end
51
+ end
52
+
53
+ def find_health_check_by_tag(key, value)
54
+ list_health_checks.detect do |health_check|
55
+ get_health_check_tags(health_check.id).detect { |tag| tag.key == key && tag.value.include?(value) }
56
+ end
57
+ end
37
58
  end
38
59
  end
39
60
  end
@@ -50,6 +50,7 @@ module MovableInk
50
50
  Aws::SNS::Errors::ThrottledException,
51
51
  Aws::AutoScaling::Errors::ThrottledException,
52
52
  Aws::S3::Errors::SlowDown,
53
+ Aws::Route53::Errors::Throttling,
53
54
  Aws::Route53::Errors::ThrottlingException,
54
55
  Aws::Route53::Errors::PriorRequestNotComplete,
55
56
  Aws::SSM::Errors::TooManyUpdates,
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
5
5
  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: 0.3.2
4
+ version: 0.3.3
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-05-29 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk