sport_ngin_aws_auditor 4.0.0 → 4.0.1

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
  SHA1:
3
- metadata.gz: 426f863fd847de5399249f6e81575fcdef99ae29
4
- data.tar.gz: 8ad69c1ef79d4e0b3b92c59264655c28b719c001
3
+ metadata.gz: 33ff924df614bb4d8e056200750c9775c0fcc315
4
+ data.tar.gz: 10a1994780b54551f47de7e4694578ae5a2e24e6
5
5
  SHA512:
6
- metadata.gz: 52a07a51a83b4229dc3df8ce7bac6685f0b19b369ea01f100a637ae35876c06e2b4a1044a69f4d15bf7913c6114519db72144a420790bf8efa32a396cdb5a81b
7
- data.tar.gz: bb2bbf9806d201085f611f18c6cff3439b71dcb32a6397d2bb8a059a6fca3925442b2aa522d0f1f5f74b81b3f96ee36e93207ee233648c33e70cb6a53160fa0a
6
+ metadata.gz: a0e52ae4fb44a5f22b05b328f3e672ce28398546a332d743df5eeaa6f093297e698e97484091976b547faa0f472f8d99ed299491ad934ba92cd552ef5ab6a5e0
7
+ data.tar.gz: ded631320ab25cb82105342458693a3bef36c2c0fe6d2aaede106ffbc92233c9c2ef3a7c36c29561843f4d822961d50ff84c654027c29011b27b8a6f5a2e12d1
data/CHANGELOG.markdown CHANGED
@@ -0,0 +1,132 @@
1
+ #### v4.0.1
2
+ * Concat all of the similar values into one value right before printing
3
+
4
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/27
5
+
6
+ #### v4.0.0
7
+ * Adding abilities to audit cross account
8
+
9
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/31
10
+
11
+ #### v3.11.3
12
+ * Missed this bug because I did not test previous bug's fix in Slack
13
+
14
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/30
15
+
16
+ #### v3.11.2
17
+ * We actually do not want to cache the counts of instances and reserved instances between multiple runs
18
+
19
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/29
20
+
21
+ #### v3.11.1
22
+ * Must merge this PR in to run the audit command correctly
23
+
24
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/28
25
+
26
+ #### v3.11.0
27
+ * Automatically ignore instances based on a regex string
28
+
29
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/26
30
+
31
+ #### v3.10.1
32
+ * Caching should not affect RI counts between runs
33
+
34
+ > Emma Sax: Andy Fleener, Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/25
35
+
36
+ #### v3.10.0
37
+ * Handling region-based RIs
38
+
39
+ > Emma Sax: Andy Fleener, Luke Ludwig, Tim Sandquist, Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/21
40
+
41
+ #### v3.9.0
42
+ * Add the ability to pass config data in as a flag
43
+
44
+ > Emma Sax: Andy Fleener, Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/24
45
+
46
+ #### v3.8.3
47
+ * Fixing bugs with outputs and counts
48
+
49
+ > Emma Sax: Tim Sandquist, Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/23
50
+
51
+ #### v3.8.2
52
+ * Fixing bugs so that counts are accurate again
53
+
54
+ > Emma Sax: : https://github.com/sportngin/sport_ngin_aws_auditor/pull/20
55
+
56
+ #### v3.8.1
57
+ #### v3.8.0
58
+ * Clarifying printout of audit command
59
+
60
+ > Emma Sax: : https://github.com/sportngin/sport_ngin_aws_auditor/pull/18
61
+
62
+ #### v3.7.0
63
+ * Print retired tags into slack/terminal on audit
64
+
65
+ > Emma Sax: Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/17
66
+
67
+ #### v3.6.0
68
+ * Print reserved instances that have retired in past week
69
+
70
+ > Emma Sax: Andy Fleener: https://github.com/sportngin/sport_ngin_aws_auditor/pull/16
71
+
72
+ #### v3.5.0
73
+ * Cleaning up slack printouts with the audit command
74
+
75
+ > Emma Sax: Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/15
76
+
77
+ #### v3.4.1
78
+ #### v3.4.0
79
+ * Add other RDS engine types
80
+
81
+ > matl33t: Emma Sax, Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/11
82
+
83
+ #### v3.3.1
84
+ * Fixing bug where Slack will print discrepancies if there are *only* tagged instances
85
+
86
+ > Emma Sax: : https://github.com/sportngin/sport_ngin_aws_auditor/pull/13
87
+
88
+ #### v3.3.0
89
+ * Slack should print instances that have tags
90
+
91
+ > Emma Sax: Andy Fleener: https://github.com/sportngin/sport_ngin_aws_auditor/pull/12
92
+
93
+ #### v3.2.0
94
+ * Proper recognition of windows/linux/vpc instances
95
+
96
+ > Emma Sax: Andy Fleener: https://github.com/sportngin/sport_ngin_aws_auditor/pull/8
97
+
98
+ #### v3.1.2
99
+ #### v3.1.0
100
+ * Authentication with AWS roles instead of credentials file
101
+
102
+ > Emma Sax: Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/7
103
+
104
+ #### v3.0.2
105
+ #### v3.0.1
106
+ #### v3.0.0
107
+ * Rename gem directories and modules
108
+
109
+ > Emma Sax: Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/6
110
+
111
+ #### v2.1.0
112
+ * Adding option to print audit results to Slack channel
113
+
114
+ > Emma Sax, Matt Krieger: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/4
115
+
116
+ * Adding option to print audit results to Slack channel
117
+
118
+ > Emma Sax, Matt Krieger: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/4
119
+
120
+ #### v2.0.0
121
+ * Adding enhancements for taking no-reserved-instance tag into consideration during audit
122
+
123
+ > Emma Sax: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/2
124
+
125
+ #### v1.0.0
126
+ * Upgrading aws-sdk version from v1 to v2
127
+
128
+ > Emma Sax: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/3
129
+
130
+ * First tests, Travis CI, MFA support, and fog file compatibility
131
+
132
+ > Brian Bergstrom: Emma Sax: https://github.com/sportngin/aws_auditor/pull/1
@@ -4,17 +4,24 @@ module SportNginAwsAuditor
4
4
  class Instance
5
5
  extend InstanceHelper
6
6
 
7
- attr_accessor :type, :count, :category, :tag_value, :reason, :name, :region_based
8
- def initialize(type, data_hash, region)
9
- if type.include?(" with tag")
10
- gather_tagged_data(type, data_hash, region)
11
- elsif type.include?(" ignored")
12
- gather_ignored_data(type, data_hash, region)
7
+ attr_accessor :type, :count, :category, :tag_value, :reason, :name, :region_based, :replaced
8
+ def initialize(type, data_hash, region, category=nil, count=nil)
9
+ if category && count
10
+ self.type = type
11
+ self.category = category
12
+ self.count = count
13
13
  else
14
- gather_normal_data(type, data_hash, region)
14
+ if type.include?(" with tag")
15
+ gather_tagged_data(type, data_hash, region)
16
+ elsif type.include?(" ignored")
17
+ gather_ignored_data(type, data_hash, region)
18
+ else
19
+ gather_normal_data(type, data_hash, region)
20
+ end
21
+
22
+ self.count = data_hash[:count].abs
23
+ self.replaced = false
15
24
  end
16
-
17
- self.count = data_hash[:count].abs
18
25
  end
19
26
 
20
27
  def gather_tagged_data(type, data_hash, region)
@@ -46,6 +46,11 @@ module SportNginAwsAuditor
46
46
  end
47
47
 
48
48
  def self.print_audit_results(region)
49
+ @audit_results.data.each do |instance|
50
+ instance.type = !@zone_output && (instance.tagged? || instance.running?) ? print_without_zone(instance.type) : instance.type
51
+ end
52
+
53
+ @audit_results.data = merge_similar_keys(@audit_results.data)
49
54
  @audit_results.data.sort_by! { |instance| [instance.category, instance.type] }
50
55
 
51
56
  if @slack
@@ -67,7 +72,7 @@ module SportNginAwsAuditor
67
72
 
68
73
  def self.say_instances
69
74
  @audit_results.data.each do |instance|
70
- name = !@zone_output && (instance.tagged? || instance.running?) ? print_without_zone(instance.type) : instance.type
75
+ name = instance.type
71
76
  count = instance.count
72
77
  color, rgb, prefix = color_chooser({:instance => instance, :retired_ri => false, :retired_tag => false})
73
78
 
@@ -142,24 +147,24 @@ module SportNginAwsAuditor
142
147
  end
143
148
 
144
149
  def self.print_instances
145
- data_array = @audit_results.data.reject { |data| data.matched? }
150
+ data_array = @audit_results.data.reject { |instance| instance.matched? }
146
151
 
147
152
  if data_array.empty?
148
153
  @slack_message.attachments.push({"color" => "#32CD32", "text" => "All RIs are properly matched here!", "mrkdwn_in" => ["text"]})
149
154
  else
150
- data_array.each do |data|
151
- type = !@zone_output && (data.tagged? || data.running?) ? print_without_zone(data.type) : data.type
152
- count = data.count
153
- color, rgb, prefix = color_chooser({:instance => data, :retired_ri => false, :retired_tag => false})
154
-
155
- if data.tagged?
156
- if data.reason
157
- text = "#{prefix} #{data.name}: (expiring on #{data.tag_value} because #{data.reason})"
155
+ data_array.each do |instance|
156
+ type = instance.type
157
+ count = instance.count
158
+ color, rgb, prefix = color_chooser({:instance => instance, :retired_ri => false, :retired_tag => false})
159
+
160
+ if instance.tagged?
161
+ if instance.reason
162
+ text = "#{prefix} #{instance.name}: (expiring on #{instance.tag_value} because #{instance.reason})"
158
163
  else
159
- text = "#{prefix} #{data.name}: (expiring on #{data.tag_value})"
164
+ text = "#{prefix} #{instance.name}: (expiring on #{instance.tag_value})"
160
165
  end
161
- elsif data.ignored?
162
- text = "#{prefix} #{data.name}"
166
+ elsif instance.ignored?
167
+ text = "#{prefix} #{instance.name}"
163
168
  else
164
169
  text = "#{prefix} #{type}: #{count}"
165
170
  end
@@ -289,6 +294,32 @@ module SportNginAwsAuditor
289
294
  type.sub(/(-\d\w)/, '')
290
295
  end
291
296
 
297
+ def self.merge_similar_keys(original_data)
298
+ combined_data = []
299
+
300
+ original_data.each_with_index do |instance, index|
301
+ new_count = instance.count
302
+
303
+ unless instance.replaced
304
+ for i in index+1..original_data.length-1
305
+ if (original_data[i].type == instance.type) && ((original_data[i].running? && instance.running?) ||
306
+ (original_data[i].reserved? && instance.reserved?) ||
307
+ (original_data[i].matched? && instance.matched?))
308
+ new_count = new_count + original_data[i].count
309
+ original_data[i].replaced = true
310
+ end
311
+ end
312
+
313
+ if new_count != instance.count
314
+ combined_data.push(Instance.new(instance.type, nil, nil, instance.category, new_count))
315
+ instance.replaced = true
316
+ end
317
+ end
318
+ end
319
+
320
+ original_data.reject { |instance| instance.replaced }.concat(combined_data)
321
+ end
322
+
292
323
  def self.color_chooser(data)
293
324
  if data[:retired_ri]
294
325
  return :light_black, "#595959", "RETIRED RI -"
@@ -1,3 +1,3 @@
1
1
  module SportNginAwsAuditor
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sport_ngin_aws_auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Hursh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-01-05 00:00:00.000000000 Z
13
+ date: 2017-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk