sport_ngin_aws_auditor 3.3.1 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +6 -0
- data/lib/sport_ngin_aws_auditor/cache_instance.rb +18 -19
- data/lib/sport_ngin_aws_auditor/ec2_instance.rb +43 -44
- data/lib/sport_ngin_aws_auditor/rds_instance.rb +47 -24
- data/lib/sport_ngin_aws_auditor/version.rb +1 -1
- data/spec/sport_ngin_aws_auditor/cache_instance_spec.rb +7 -7
- data/spec/sport_ngin_aws_auditor/ec2_instance_spec.rb +15 -15
- data/spec/sport_ngin_aws_auditor/rds_instance_spec.rb +14 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d049590c2efaa67e2070d04f7882d6a615040e91
|
4
|
+
data.tar.gz: 6107c00771383ba9886aef453c96e5f823057c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d503ffdeb1338db137c930e9cdfb2e8b73e17f7be293134c22bdfdb9528e10d8af6119a4217f4ced95978fcb2a61c00011ca0755d17995231de1a0c33d7aadf
|
7
|
+
data.tar.gz: 27f60395d9b9e72bd4abd51ce19e45e2cb90edbfb163bab1e81b3d21e55242a73ebc9e35d113a97fb8715b35693ea123ad107234617197e1654924c951953a91
|
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
#### v3.4.1
|
2
|
+
#### v3.4.0
|
3
|
+
* Add other RDS engine types
|
4
|
+
|
5
|
+
> matl33t: Emma Sax, Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/11
|
6
|
+
|
1
7
|
#### v3.3.1
|
2
8
|
* Fixing bug where Slack will print discrepancies if there are *only* tagged instances
|
3
9
|
|
@@ -8,6 +8,23 @@ module SportNginAwsAuditor
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
attr_accessor :instances, :reserved_instances
|
11
|
+
|
12
|
+
def get_instances(tag_name=nil)
|
13
|
+
return @instances if @instances
|
14
|
+
account_id = get_account_id
|
15
|
+
@instances = cache.describe_cache_clusters.cache_clusters.map do |instance|
|
16
|
+
next unless instance.cache_cluster_status.to_s == 'available'
|
17
|
+
new(instance, account_id, tag_name, cache)
|
18
|
+
end.compact
|
19
|
+
end
|
20
|
+
|
21
|
+
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|
|
24
|
+
next unless instance.state.to_s == 'active'
|
25
|
+
new(instance)
|
26
|
+
end.compact
|
27
|
+
end
|
11
28
|
end
|
12
29
|
|
13
30
|
attr_accessor :id, :name, :instance_type, :engine, :count, :tag_value
|
@@ -30,7 +47,7 @@ module SportNginAwsAuditor
|
|
30
47
|
region = "us-east-1" if region == "Multiple"
|
31
48
|
arn = "arn:aws:elasticache:#{region}:#{account_id}:cluster:#{self.id}"
|
32
49
|
|
33
|
-
|
50
|
+
# go through to see if the tag we're looking for is one of them
|
34
51
|
cache.list_tags_for_resource(resource_name: arn).tag_list.each do |tag|
|
35
52
|
if tag.key == tag_name
|
36
53
|
self.tag_value = tag.value
|
@@ -44,26 +61,8 @@ module SportNginAwsAuditor
|
|
44
61
|
"#{engine.capitalize} #{instance_type}"
|
45
62
|
end
|
46
63
|
|
47
|
-
def self.get_instances(tag_name=nil)
|
48
|
-
return @instances if @instances
|
49
|
-
account_id = get_account_id
|
50
|
-
@instances = cache.describe_cache_clusters.cache_clusters.map do |instance|
|
51
|
-
next unless instance.cache_cluster_status.to_s == 'available'
|
52
|
-
new(instance, account_id, tag_name, cache)
|
53
|
-
end.compact
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.get_reserved_instances
|
57
|
-
return @reserved_instances if @reserved_instances
|
58
|
-
@reserved_instances = cache.describe_reserved_cache_nodes.reserved_cache_nodes.map do |instance|
|
59
|
-
next unless instance.state.to_s == 'active'
|
60
|
-
new(instance)
|
61
|
-
end.compact
|
62
|
-
end
|
63
|
-
|
64
64
|
def no_reserved_instance_tag_value
|
65
65
|
@tag_value
|
66
66
|
end
|
67
|
-
|
68
67
|
end
|
69
68
|
end
|
@@ -7,6 +7,49 @@ module SportNginAwsAuditor
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
attr_accessor :instances, :reserved_instances
|
10
|
+
|
11
|
+
def get_instances(tag_name=nil)
|
12
|
+
return @instances if @instances
|
13
|
+
@instances = ec2.describe_instances.reservations.map do |reservation|
|
14
|
+
reservation.instances.map do |instance|
|
15
|
+
next unless instance.state.name == 'running'
|
16
|
+
new(instance, tag_name)
|
17
|
+
end.compact
|
18
|
+
end.flatten.compact
|
19
|
+
get_more_info
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_reserved_instances
|
23
|
+
return @reserved_instances if @reserved_instances
|
24
|
+
@reserved_instances = ec2.describe_reserved_instances.reserved_instances.map do |ri|
|
25
|
+
next unless ri.state == 'active'
|
26
|
+
new(ri, nil, ri.instance_count)
|
27
|
+
end.compact
|
28
|
+
end
|
29
|
+
|
30
|
+
def bucketize
|
31
|
+
buckets = {}
|
32
|
+
get_instances.map do |instance|
|
33
|
+
name = instance.stack_name || instance.name
|
34
|
+
if name
|
35
|
+
buckets[name] = [] unless buckets.has_key? name
|
36
|
+
buckets[name] << instance
|
37
|
+
else
|
38
|
+
puts "Could not sort #{instance.id}, as it has no stack_name or name"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
buckets.sort_by{|k,v| k }
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_more_info
|
45
|
+
get_instances.each do |instance|
|
46
|
+
tags = ec2.describe_tags(:filters => [{:name => "resource-id", :values => [instance.id]}]).tags
|
47
|
+
tags = Hash[tags.map { |tag| [tag[:key], tag[:value]]}.compact]
|
48
|
+
instance.name = tags["Name"]
|
49
|
+
instance.stack_name = tags["opsworks:stack"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
private :get_more_info
|
10
53
|
end
|
11
54
|
|
12
55
|
attr_accessor :id, :name, :platform, :availability_zone, :instance_type, :count, :stack_name, :tag_value
|
@@ -43,25 +86,6 @@ module SportNginAwsAuditor
|
|
43
86
|
"#{platform} #{availability_zone} #{instance_type}"
|
44
87
|
end
|
45
88
|
|
46
|
-
def self.get_instances(tag_name=nil)
|
47
|
-
return @instances if @instances
|
48
|
-
@instances = ec2.describe_instances.reservations.map do |reservation|
|
49
|
-
reservation.instances.map do |instance|
|
50
|
-
next unless instance.state.name == 'running'
|
51
|
-
new(instance, tag_name)
|
52
|
-
end.compact
|
53
|
-
end.flatten.compact
|
54
|
-
get_more_info
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.get_reserved_instances
|
58
|
-
return @reserved_instances if @reserved_instances
|
59
|
-
@reserved_instances = ec2.describe_reserved_instances.reserved_instances.map do |ri|
|
60
|
-
next unless ri.state == 'active'
|
61
|
-
new(ri, nil, ri.instance_count)
|
62
|
-
end.compact
|
63
|
-
end
|
64
|
-
|
65
89
|
def no_reserved_instance_tag_value
|
66
90
|
@tag_value
|
67
91
|
end
|
@@ -82,30 +106,5 @@ module SportNginAwsAuditor
|
|
82
106
|
return platform
|
83
107
|
end
|
84
108
|
private :platform_helper
|
85
|
-
|
86
|
-
def self.get_more_info
|
87
|
-
get_instances.each do |instance|
|
88
|
-
tags = ec2.describe_tags(:filters => [{:name => "resource-id", :values => [instance.id]}]).tags
|
89
|
-
tags = Hash[tags.map { |tag| [tag[:key], tag[:value]]}.compact]
|
90
|
-
instance.name = tags["Name"]
|
91
|
-
instance.stack_name = tags["opsworks:stack"]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
private_class_method :get_more_info
|
95
|
-
|
96
|
-
def self.bucketize
|
97
|
-
buckets = {}
|
98
|
-
get_instances.map do |instance|
|
99
|
-
name = instance.stack_name || instance.name
|
100
|
-
if name
|
101
|
-
buckets[name] = [] unless buckets.has_key? name
|
102
|
-
buckets[name] << instance
|
103
|
-
else
|
104
|
-
puts "Could not sort #{instance.id}, as it has no stack_name or name"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
buckets.sort_by{|k,v| k }
|
108
|
-
end
|
109
|
-
|
110
109
|
end
|
111
110
|
end
|
@@ -8,6 +8,23 @@ module SportNginAwsAuditor
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
attr_accessor :instances, :reserved_instances
|
11
|
+
|
12
|
+
def get_instances(tag_name=nil)
|
13
|
+
return @instances if @instances
|
14
|
+
account_id = get_account_id
|
15
|
+
@instances = rds.describe_db_instances.db_instances.map do |instance|
|
16
|
+
next unless instance.db_instance_status.to_s == 'available'
|
17
|
+
new(instance, account_id, tag_name, rds)
|
18
|
+
end.compact
|
19
|
+
end
|
20
|
+
|
21
|
+
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|
|
24
|
+
next unless instance.state.to_s == 'active'
|
25
|
+
new(instance)
|
26
|
+
end.compact
|
27
|
+
end
|
11
28
|
end
|
12
29
|
|
13
30
|
attr_accessor :id, :name, :multi_az, :instance_type, :engine, :count, :tag_value
|
@@ -17,7 +34,7 @@ module SportNginAwsAuditor
|
|
17
34
|
self.multi_az = rds_instance.multi_az ? "Multi-AZ" : "Single-AZ"
|
18
35
|
self.instance_type = rds_instance.db_instance_class
|
19
36
|
self.engine = engine_helper(rds_instance.product_description)
|
20
|
-
self.count =
|
37
|
+
self.count = rds_instance.db_instance_count
|
21
38
|
elsif rds_instance.class.to_s == "Aws::RDS::Types::DBInstance"
|
22
39
|
self.id = rds_instance.db_instance_identifier
|
23
40
|
self.multi_az = rds_instance.multi_az ? "Multi-AZ" : "Single-AZ"
|
@@ -44,35 +61,41 @@ module SportNginAwsAuditor
|
|
44
61
|
"#{engine} #{multi_az} #{instance_type}"
|
45
62
|
end
|
46
63
|
|
47
|
-
def self.get_instances(tag_name=nil)
|
48
|
-
return @instances if @instances
|
49
|
-
account_id = get_account_id
|
50
|
-
@instances = rds.describe_db_instances.db_instances.map do |instance|
|
51
|
-
next unless instance.db_instance_status.to_s == 'available'
|
52
|
-
new(instance, account_id, tag_name, rds)
|
53
|
-
end.compact
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.get_reserved_instances
|
57
|
-
return @reserved_instances if @reserved_instances
|
58
|
-
@reserved_instances = rds.describe_reserved_db_instances.reserved_db_instances.map do |instance|
|
59
|
-
next unless instance.state.to_s == 'active'
|
60
|
-
new(instance)
|
61
|
-
end.compact
|
62
|
-
end
|
63
|
-
|
64
64
|
def no_reserved_instance_tag_value
|
65
|
-
|
65
|
+
tag_value
|
66
66
|
end
|
67
67
|
|
68
|
+
# Generates a name based on the RDS engine or product description
|
68
69
|
def engine_helper(engine)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
case engine.downcase
|
71
|
+
when 'aurora'
|
72
|
+
'Aurora'
|
73
|
+
when 'mariadb'
|
74
|
+
'MariaDB'
|
75
|
+
when 'mysql'
|
76
|
+
'MySQL'
|
77
|
+
when 'oracle-ee', 'oracle-ee(byol)'
|
78
|
+
'Oracle EE'
|
79
|
+
when 'oracle-se', 'oracle-se(byol)'
|
80
|
+
'Oracle SE'
|
81
|
+
when 'oracle-se1', 'oracle-se1(li)'
|
82
|
+
'Oracle SE One'
|
83
|
+
when 'oracle-se2', 'oracle-se2 (byol)' # extra space required
|
84
|
+
'Oracle SE Two'
|
85
|
+
when 'postgres', 'postgresql'
|
86
|
+
'PostgreSQL'
|
87
|
+
when 'sqlserver-ee', 'sqlserver-ee(li)'
|
88
|
+
'SQL Server EE'
|
89
|
+
when 'sqlserver-ex', 'sqlserver-ex(li)'
|
90
|
+
'SQL Server EX'
|
91
|
+
when 'sqlserver-se', 'sqlserver-se(byol)'
|
92
|
+
'SQL Server SE'
|
93
|
+
when 'sqlserver-web', 'sqlserver-web(li)'
|
94
|
+
'SQL Server Web'
|
95
|
+
else
|
96
|
+
'Unknown DB Engine'
|
73
97
|
end
|
74
98
|
end
|
75
99
|
private :engine_helper
|
76
|
-
|
77
100
|
end
|
78
101
|
end
|
@@ -39,19 +39,19 @@ module SportNginAwsAuditor
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should make a cache_instance for each instance" do
|
42
|
-
instances = CacheInstance
|
42
|
+
instances = CacheInstance.get_instances("tag_name")
|
43
43
|
expect(instances.first).to be_an_instance_of(CacheInstance)
|
44
44
|
expect(instances.last).to be_an_instance_of(CacheInstance)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return an array of cache_instances" do
|
48
|
-
instances = CacheInstance
|
48
|
+
instances = CacheInstance.get_instances("tag_name")
|
49
49
|
expect(instances).not_to be_empty
|
50
50
|
expect(instances.length).to eq(2)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should have proper variables set" do
|
54
|
-
instances = CacheInstance
|
54
|
+
instances = CacheInstance.get_instances("tag_name")
|
55
55
|
instance = instances.first
|
56
56
|
expect(instance.id).to eq("job-queue-cluster")
|
57
57
|
expect(instance.name).to eq("job-queue-cluster")
|
@@ -80,19 +80,19 @@ module SportNginAwsAuditor
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should make a reserved_cache_instance for each instance" do
|
83
|
-
reserved_instances = CacheInstance
|
83
|
+
reserved_instances = CacheInstance.get_reserved_instances
|
84
84
|
expect(reserved_instances.first).to be_an_instance_of(CacheInstance)
|
85
85
|
expect(reserved_instances.last).to be_an_instance_of(CacheInstance)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should return an array of reserved_cache_instances" do
|
89
|
-
reserved_instances = CacheInstance
|
89
|
+
reserved_instances = CacheInstance.get_reserved_instances
|
90
90
|
expect(reserved_instances).not_to be_empty
|
91
91
|
expect(reserved_instances.length).to eq(2)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should have proper variables set" do
|
95
|
-
reserved_instances = CacheInstance
|
95
|
+
reserved_instances = CacheInstance.get_reserved_instances
|
96
96
|
reserved_instance = reserved_instances.first
|
97
97
|
expect(reserved_instance.id).to eq("job-queue-cluster")
|
98
98
|
expect(reserved_instance.name).to eq("job-queue-cluster")
|
@@ -116,7 +116,7 @@ module SportNginAwsAuditor
|
|
116
116
|
tags = double('tags', tag_list: [tag1, tag2])
|
117
117
|
cache_client = double('cache_client', describe_cache_clusters: cache_clusters, list_tags_for_resource: tags)
|
118
118
|
allow(CacheInstance).to receive(:cache).and_return(cache_client)
|
119
|
-
instances = CacheInstance
|
119
|
+
instances = CacheInstance.get_instances("tag_name")
|
120
120
|
instance = instances.first
|
121
121
|
expect(instance.to_s).to eq("Redis cache.t2.small")
|
122
122
|
end
|
@@ -41,19 +41,19 @@ module SportNginAwsAuditor
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should make an ec2_instance for each instance" do
|
44
|
-
instances = EC2Instance
|
44
|
+
instances = EC2Instance.get_instances("tag_name")
|
45
45
|
expect(instances.first).to be_an_instance_of(EC2Instance)
|
46
46
|
expect(instances.last).to be_an_instance_of(EC2Instance)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return an array of ec2_instances" do
|
50
|
-
instances = EC2Instance
|
50
|
+
instances = EC2Instance.get_instances("tag_name")
|
51
51
|
expect(instances).not_to be_empty
|
52
52
|
expect(instances.length).to eq(2)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should have proper variables set" do
|
56
|
-
instances = EC2Instance
|
56
|
+
instances = EC2Instance.get_instances("tag_name")
|
57
57
|
instance = instances.first
|
58
58
|
expect(instance.stack_name).to eq("our_app_service_2")
|
59
59
|
expect(instance.name).to eq("our-app-instance-100")
|
@@ -64,7 +64,7 @@ module SportNginAwsAuditor
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should recognize Windows vs. Linux" do
|
67
|
-
instances = EC2Instance
|
67
|
+
instances = EC2Instance.get_instances("tag_name")
|
68
68
|
instance1 = instances.first
|
69
69
|
instance2 = instances.last
|
70
70
|
expect(instance1.platform).to eq("Linux VPC")
|
@@ -94,19 +94,19 @@ module SportNginAwsAuditor
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should make a reserved_ec2_instance for each instance" do
|
97
|
-
reserved_instances = EC2Instance
|
97
|
+
reserved_instances = EC2Instance.get_reserved_instances
|
98
98
|
expect(reserved_instances.first).to be_an_instance_of(EC2Instance)
|
99
99
|
expect(reserved_instances.last).to be_an_instance_of(EC2Instance)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should return an array of reserved_ec2_instances" do
|
103
|
-
reserved_instances = EC2Instance
|
103
|
+
reserved_instances = EC2Instance.get_reserved_instances
|
104
104
|
expect(reserved_instances).not_to be_empty
|
105
105
|
expect(reserved_instances.length).to eq(2)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should have proper variables set" do
|
109
|
-
reserved_instances = EC2Instance
|
109
|
+
reserved_instances = EC2Instance.get_reserved_instances
|
110
110
|
reserved_instance = reserved_instances.first
|
111
111
|
expect(reserved_instance.id).to eq("12345-dfas-1234-asdf-thisisfake!!")
|
112
112
|
expect(reserved_instance.platform).to eq("Windows VPC")
|
@@ -116,7 +116,7 @@ module SportNginAwsAuditor
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should recognize Windows vs. Linux" do
|
119
|
-
reserved_instances = EC2Instance
|
119
|
+
reserved_instances = EC2Instance.get_reserved_instances
|
120
120
|
reserved_instance1 = reserved_instances.first
|
121
121
|
reserved_instance2 = reserved_instances.last
|
122
122
|
expect(reserved_instance1.platform).to eq("Windows VPC")
|
@@ -146,7 +146,7 @@ module SportNginAwsAuditor
|
|
146
146
|
tags = double('tags', tags: [name_tag, stack_tag])
|
147
147
|
ec2_client = double('ec2_client', describe_instances: ec2_instances, describe_tags: tags)
|
148
148
|
allow(EC2Instance).to receive(:ec2).and_return(ec2_client)
|
149
|
-
instances = EC2Instance
|
149
|
+
instances = EC2Instance.get_instances("tag_name")
|
150
150
|
instance = instances.first
|
151
151
|
expect(instance.to_s).to eq("Linux VPC us-east-1d t2.large")
|
152
152
|
end
|
@@ -180,20 +180,20 @@ module SportNginAwsAuditor
|
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should return a hash where the first element's key is the opsworks:stack name of the instances" do
|
183
|
-
instances = EC2Instance
|
184
|
-
buckets = EC2Instance
|
183
|
+
instances = EC2Instance.get_instances
|
184
|
+
buckets = EC2Instance.bucketize
|
185
185
|
expect(buckets.first.first).to eq("our_app_service_2")
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should return a hash where the last element's key is the opsworks:stack name of the instances" do
|
189
|
-
instances = EC2Instance
|
190
|
-
buckets = EC2Instance
|
189
|
+
instances = EC2Instance.get_instances
|
190
|
+
buckets = EC2Instance.bucketize
|
191
191
|
expect(buckets.last.first).to eq("our_app_service_2")
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should return a hash where each element is a list of ec2_instances" do
|
195
|
-
instances = EC2Instance
|
196
|
-
buckets = EC2Instance
|
195
|
+
instances = EC2Instance.get_instances
|
196
|
+
buckets = EC2Instance.bucketize
|
197
197
|
expect(buckets).not_to be_empty
|
198
198
|
expect(buckets.length).to eq(1)
|
199
199
|
expect(buckets.first.length).to eq(2)
|
@@ -39,19 +39,19 @@ module SportNginAwsAuditor
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should make a rds_instance for each instance" do
|
42
|
-
instances = RDSInstance
|
42
|
+
instances = RDSInstance.get_instances("tag_name")
|
43
43
|
expect(instances.first).to be_an_instance_of(RDSInstance)
|
44
44
|
expect(instances.last).to be_an_instance_of(RDSInstance)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return an array of rds_instances" do
|
48
|
-
instances = RDSInstance
|
48
|
+
instances = RDSInstance.get_instances("tag_name")
|
49
49
|
expect(instances).not_to be_empty
|
50
50
|
expect(instances.length).to eq(2)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should have proper variables set" do
|
54
|
-
instances = RDSInstance
|
54
|
+
instances = RDSInstance.get_instances("tag_name")
|
55
55
|
instance = instances.first
|
56
56
|
expect(instance.id).to eq("our-service")
|
57
57
|
expect(instance.multi_az).to eq("Single-AZ")
|
@@ -66,13 +66,15 @@ module SportNginAwsAuditor
|
|
66
66
|
multi_az: false,
|
67
67
|
db_instance_class: "db.t2.small",
|
68
68
|
state: "active",
|
69
|
-
product_description: "
|
69
|
+
product_description: "oracle-se2 (byol)",
|
70
|
+
db_instance_count: 1,
|
70
71
|
class: "Aws::RDS::Types::ReservedDBInstance")
|
71
72
|
reserved_rds_instance2 = double('reserved_rds_instance', reserved_db_instances_offering_id: "555te4yy-1234-555c-5678-thisisafake!!",
|
72
73
|
multi_az: false,
|
73
74
|
db_instance_class: "db.m3.large",
|
74
75
|
state: "active",
|
75
76
|
product_description: "postgresql",
|
77
|
+
db_instance_count: 2,
|
76
78
|
class: "Aws::RDS::Types::ReservedDBInstance")
|
77
79
|
reserved_db_instances = double('db_instances', reserved_db_instances: [reserved_rds_instance1, reserved_rds_instance2])
|
78
80
|
rds_client = double('rds_client', describe_reserved_db_instances: reserved_db_instances)
|
@@ -80,24 +82,24 @@ module SportNginAwsAuditor
|
|
80
82
|
end
|
81
83
|
|
82
84
|
it "should make a reserved_rds_instance for each instance" do
|
83
|
-
reserved_instances = RDSInstance
|
85
|
+
reserved_instances = RDSInstance.get_reserved_instances
|
84
86
|
expect(reserved_instances.first).to be_an_instance_of(RDSInstance)
|
85
87
|
expect(reserved_instances.last).to be_an_instance_of(RDSInstance)
|
86
88
|
end
|
87
89
|
|
88
90
|
it "should return an array of reserved_rds_instances" do
|
89
|
-
reserved_instances = RDSInstance
|
91
|
+
reserved_instances = RDSInstance.get_reserved_instances
|
90
92
|
expect(reserved_instances).not_to be_empty
|
91
93
|
expect(reserved_instances.length).to eq(2)
|
92
94
|
end
|
93
95
|
|
94
96
|
it "should have proper variables set" do
|
95
|
-
reserved_instances = RDSInstance
|
97
|
+
reserved_instances = RDSInstance.get_reserved_instances
|
96
98
|
reserved_instance = reserved_instances.first
|
97
99
|
expect(reserved_instance.id).to eq("555te4yy-1234-555c-5678-thisisafake!!")
|
98
100
|
expect(reserved_instance.multi_az).to eq("Single-AZ")
|
99
101
|
expect(reserved_instance.instance_type).to eq("db.t2.small")
|
100
|
-
expect(reserved_instance.engine).to eq("
|
102
|
+
expect(reserved_instance.engine).to eq("Oracle SE Two")
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
@@ -108,11 +110,12 @@ module SportNginAwsAuditor
|
|
108
110
|
db_instance_class: "db.t2.small",
|
109
111
|
state: "active",
|
110
112
|
product_description: "mysql",
|
113
|
+
db_instance_count: 3,
|
111
114
|
class: "Aws::RDS::Types::ReservedDBInstance")
|
112
115
|
reserved_db_instances = double('db_instances', reserved_db_instances: [reserved_rds_instance])
|
113
116
|
rds_client = double('rds_client', describe_reserved_db_instances: reserved_db_instances)
|
114
117
|
allow(RDSInstance).to receive(:rds).and_return(rds_client)
|
115
|
-
reserved_instances = RDSInstance
|
118
|
+
reserved_instances = RDSInstance.get_reserved_instances
|
116
119
|
reserved_instance = reserved_instances.first
|
117
120
|
expect(reserved_instance.to_s).to eq("MySQL Single-AZ db.t2.small")
|
118
121
|
end
|
@@ -122,7 +125,7 @@ module SportNginAwsAuditor
|
|
122
125
|
multi_az: false,
|
123
126
|
db_instance_class: "db.t2.small",
|
124
127
|
db_instance_status: "available",
|
125
|
-
engine: "
|
128
|
+
engine: "postgres",
|
126
129
|
availability_zone: "us-east-1a",
|
127
130
|
class: "Aws::RDS::Types::DBInstance")
|
128
131
|
db_instances = double('db_instances', db_instances: [rds_instance])
|
@@ -131,7 +134,7 @@ module SportNginAwsAuditor
|
|
131
134
|
tags = double('tags', tag_list: [tag1, tag2])
|
132
135
|
rds_client = double('rds_client', describe_db_instances: db_instances, list_tags_for_resource: tags)
|
133
136
|
allow(RDSInstance).to receive(:rds).and_return(rds_client)
|
134
|
-
instances = RDSInstance
|
137
|
+
instances = RDSInstance.get_instances("tag_name")
|
135
138
|
instance = instances.first
|
136
139
|
expect(instance.to_s).to eq("PostgreSQL Single-AZ db.t2.small")
|
137
140
|
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.
|
4
|
+
version: 3.4.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: 2016-07-
|
13
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|