sport_ngin_aws_auditor 3.11.1 → 3.11.2

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: a87a5662cac1e058dc24bd10461c438d7d67681a
4
- data.tar.gz: 66e2e758d04513a1ea34f448a61837c11a0fc4eb
3
+ metadata.gz: 9b78fd1868472a038023d6d6ff2e308514871566
4
+ data.tar.gz: 542d43dc284773ad7a2c7392faeae7c8211ab384
5
5
  SHA512:
6
- metadata.gz: 8eaa4a8aab67724614ef8e44698982387b358b82881c489e2928d6a70f6db204dfdc7ef99aefb0d9405e55ed86bd400f0b35d57956a01f143ed44193e154dd57
7
- data.tar.gz: 9ba84bb48f74f5ad69875ede9004696033afecb739113f49090c3b585d8f8558b458d55834e6c79ba88e800c471bd6ef7a8e2ae46c453240ee1a907677144c86
6
+ metadata.gz: 7f6705c31e48c9fbfcd38282ecf6e6a2fbbddd522150b6d8b3c007c0e2219e8f49b5f34b34fcfbd4b6bf0fe1ec9ae913c72ee82948dfb26b8ff346c52b6eef50
7
+ data.tar.gz: 5bf312a33b03a9fe3fe0e0bccb8965eddac50f48e3da5f08ee9bfddda08a52d1157ea38e12c4d85c3a1b28ea85fc66e984b72d29df8e26e20797012afa4b2726
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ #### v3.11.2
2
+ * We actually do not want to cache the counts of instances and reserved instances between multiple runs
3
+
4
+ > Emma Sax: Unknown User: https://github.com/sportngin/sport_ngin_aws_auditor/pull/29
5
+
1
6
  #### v3.11.1
2
7
  * Must merge this PR in to run the audit command correctly
3
8
 
@@ -7,40 +7,36 @@ module SportNginAwsAuditor
7
7
  extend AWSWrapper
8
8
 
9
9
  class << self
10
- attr_accessor :instances, :reserved_instances, :retired_reserved_instances
11
-
12
10
  def get_instances(tag_name=nil)
13
- return @instances if @instances
14
11
  account_id = get_account_id
15
- @instances = cache.describe_cache_clusters.cache_clusters.map do |instance|
12
+ cache.describe_cache_clusters.cache_clusters.map do |instance|
16
13
  next unless instance.cache_cluster_status.to_s == 'available'
17
14
  new(instance, account_id, tag_name, cache)
18
15
  end.compact
19
16
  end
20
17
 
21
18
  def get_reserved_instances
22
- return @reserved_instances if @reserved_instances
23
- @reserved_instances = cache.describe_reserved_cache_nodes.reserved_cache_nodes.map do |instance|
19
+ cache.describe_reserved_cache_nodes.reserved_cache_nodes.map do |instance|
24
20
  next unless instance.state.to_s == 'active'
25
21
  new(instance)
26
22
  end.compact
27
23
  end
28
24
 
29
25
  def get_retired_reserved_instances
30
- return @retired_reserved_instances if @retired_reserved_instances
31
- @retired_reserved_instances = cache.describe_reserved_cache_nodes.reserved_cache_nodes.map do |instance|
26
+ cache.describe_reserved_cache_nodes.reserved_cache_nodes.map do |instance|
32
27
  next unless instance.state == 'retired'
33
28
  new(instance)
34
29
  end.compact
35
30
  end
36
31
  end
37
32
 
38
- attr_accessor :id, :name, :instance_type, :scope, :engine, :count, :tag_value, :tag_reason, :expiration_date
33
+ attr_accessor :id, :name, :instance_type, :scope, :engine, :count, :tag_value, :tag_reason, :expiration_date, :availability_zone
39
34
  def initialize(cache_instance, account_id=nil, tag_name=nil, cache=nil)
40
35
  if cache_instance.class.to_s == "Aws::ElastiCache::Types::ReservedCacheNode"
41
36
  self.id = cache_instance.reserved_cache_node_id
42
37
  self.name = cache_instance.reserved_cache_node_id
43
38
  self.scope = nil
39
+ self.availability_zone = nil
44
40
  self.instance_type = cache_instance.cache_node_type
45
41
  self.engine = cache_instance.product_description
46
42
  self.count = cache_instance.cache_node_count
@@ -49,6 +45,7 @@ module SportNginAwsAuditor
49
45
  self.id = cache_instance.cache_cluster_id
50
46
  self.name = cache_instance.cache_cluster_id
51
47
  self.scope = nil
48
+ self.availability_zone = nil
52
49
  self.instance_type = cache_instance.cache_node_type
53
50
  self.engine = cache_instance.engine
54
51
  self.count = cache_instance.num_cache_nodes
@@ -6,30 +6,25 @@ module SportNginAwsAuditor
6
6
  extend EC2Wrapper
7
7
 
8
8
  class << self
9
- attr_accessor :instances, :reserved_instances, :retired_reserved_instances
10
-
11
9
  def get_instances(tag_name=nil)
12
- return @instances if @instances
13
- @instances = ec2.describe_instances.reservations.map do |reservation|
10
+ instances = ec2.describe_instances.reservations.map do |reservation|
14
11
  reservation.instances.map do |instance|
15
12
  next unless instance.state.name == 'running'
16
13
  new(instance, tag_name)
17
14
  end.compact
18
15
  end.flatten.compact
19
- get_more_info
16
+ get_more_info(instances)
20
17
  end
21
18
 
22
19
  def get_reserved_instances
23
- return @reserved_instances if @reserved_instances
24
- @reserved_instances = ec2.describe_reserved_instances.reserved_instances.map do |instance|
20
+ ec2.describe_reserved_instances.reserved_instances.map do |instance|
25
21
  next unless instance.state == 'active'
26
22
  new(instance, nil, instance.instance_count)
27
23
  end.compact
28
24
  end
29
25
 
30
26
  def get_retired_reserved_instances
31
- return @retired_reserved_instances if @retired_reserved_instances
32
- @retired_reserved_instances = ec2.describe_reserved_instances.reserved_instances.map do |instance|
27
+ ec2.describe_reserved_instances.reserved_instances.map do |instance|
33
28
  next unless instance.state == 'retired'
34
29
  new(instance, nil, instance.instance_count)
35
30
  end.compact
@@ -49,8 +44,8 @@ module SportNginAwsAuditor
49
44
  buckets.sort_by{|k,v| k }
50
45
  end
51
46
 
52
- def get_more_info
53
- get_instances.each do |instance|
47
+ def get_more_info(instances)
48
+ instances.each do |instance|
54
49
  tags = ec2.describe_tags(:filters => [{:name => "resource-id", :values => [instance.id]}]).tags
55
50
  tags = Hash[tags.map { |tag| [tag[:key], tag[:value]]}.compact]
56
51
  instance.name = tags["Name"]
@@ -7,28 +7,23 @@ module SportNginAwsAuditor
7
7
  extend AWSWrapper
8
8
 
9
9
  class << self
10
- attr_accessor :instances, :reserved_instances, :retired_reserved_instances
11
-
12
10
  def get_instances(tag_name=nil)
13
- return @instances if @instances
14
11
  account_id = get_account_id
15
- @instances = rds.describe_db_instances.db_instances.map do |instance|
12
+ rds.describe_db_instances.db_instances.map do |instance|
16
13
  next unless instance.db_instance_status.to_s == 'available'
17
14
  new(instance, account_id, tag_name, rds)
18
15
  end.compact
19
16
  end
20
17
 
21
18
  def get_reserved_instances
22
- return @reserved_instances if @reserved_instances
23
- @reserved_instances = rds.describe_reserved_db_instances.reserved_db_instances.map do |instance|
19
+ rds.describe_reserved_db_instances.reserved_db_instances.map do |instance|
24
20
  next unless instance.state.to_s == 'active'
25
21
  new(instance)
26
22
  end.compact
27
23
  end
28
24
 
29
25
  def get_retired_reserved_instances
30
- return @retired_reserved_instances if @retired_reserved_instances
31
- @retired_reserved_instances = rds.describe_reserved_db_instances.reserved_db_instances.map do |instance|
26
+ rds.describe_reserved_db_instances.reserved_db_instances.map do |instance|
32
27
  next unless instance.state == 'retired'
33
28
  new(instance)
34
29
  end.compact
@@ -85,7 +85,7 @@ module SportNginAwsAuditor
85
85
  # and size = 't2.small'
86
86
  size = my_match[2] if my_match
87
87
 
88
- n = platform << audit_results.region << ' ' << size
88
+ n = (platform || "") << (audit_results.region || "") << ' ' << size
89
89
  say "#{n} (#{ri.count}) on #{ri.expiration_date}"
90
90
  else
91
91
  say "#{ri.to_s} (#{ri.count}) on #{ri.expiration_date}"
@@ -98,7 +98,7 @@ module SportNginAwsAuditor
98
98
  say "The following #{output_options[:class_type]}Instance tags have recently expired in #{output_options[:environment]}:"
99
99
  retired_tags.each do |tag|
100
100
  if tag.reason
101
- say "#{tag.instance_name} (#{tag.instance_type}) retired on #{tag.value} because of #{tag.reason}"
101
+ say "#{tag.instance_name} (#{tag.instance_type}) retired on #{tag.value} because #{tag.reason}"
102
102
  else
103
103
  say "#{tag.instance_name} (#{tag.instance_type}) retired on #{tag.value}"
104
104
  end
@@ -112,7 +112,7 @@ module SportNginAwsAuditor
112
112
 
113
113
  if instance.tagged?
114
114
  if instance.reason
115
- puts "#{prefix} #{name}: (expiring on #{instance.tag_value} because of #{instance.reason})".blue
115
+ puts "#{prefix} #{name}: (expiring on #{instance.tag_value} because #{instance.reason})".blue
116
116
  else
117
117
  say "<%= color('#{prefix} #{name}: (expiring on #{instance.tag_value})', :#{color}) %>"
118
118
  end
@@ -170,7 +170,7 @@ module SportNginAwsAuditor
170
170
  end
171
171
 
172
172
  def self.print_tagged(tagged_ignored_array, output_options)
173
- title = "There are currently some tagged #{output_options[:class_type]}s in #{output_options[:environment]}:\n"
173
+ title = "There are currently some tagged or ignored #{output_options[:class_type]}s in #{output_options[:environment]}:\n"
174
174
  slack_instances = NotifySlack.new(title, options[:config_json])
175
175
 
176
176
  tagged_ignored_array.each do |tagged_or_ignored|
@@ -180,7 +180,7 @@ module SportNginAwsAuditor
180
180
 
181
181
  if tagged_or_ignored.tagged?
182
182
  if tagged_or_ignored.reason
183
- text = "#{prefix} #{tagged_or_ignored.name}: (expiring on #{tagged_or_ignored.tag_value} because of #{tagged_or_ignored.reason})"
183
+ text = "#{prefix} #{tagged_or_ignored.name}: (expiring on #{tagged_or_ignored.tag_value} because #{tagged_or_ignored.reason})"
184
184
  else
185
185
  text = "#{prefix} #{tagged_or_ignored.name}: (expiring on #{tagged_or_ignored.tag_value})"
186
186
  end
@@ -229,7 +229,7 @@ module SportNginAwsAuditor
229
229
 
230
230
  retired_tags.each do |tag|
231
231
  if tag.reason
232
- message << "*#{tag.instance_name}* (#{tag.instance_type}) retired on *#{tag.value}* because of #{tag.reason}\n"
232
+ message << "*#{tag.instance_name}* (#{tag.instance_type}) retired on *#{tag.value}* because #{tag.reason}\n"
233
233
  else
234
234
  message << "*#{tag.instance_name}* (#{tag.instance_type}) retired on *#{tag.value}*\n"
235
235
  end
@@ -1,3 +1,3 @@
1
1
  module SportNginAwsAuditor
2
- VERSION = "3.11.1"
2
+ VERSION = "3.11.2"
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: 3.11.1
4
+ version: 3.11.2
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: 2016-12-15 00:00:00.000000000 Z
13
+ date: 2016-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk