sport_ngin_aws_auditor 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +39 -0
- data/lib/sport_ngin_aws_auditor/cache_instance.rb +1 -1
- data/lib/sport_ngin_aws_auditor/ec2_instance.rb +15 -23
- data/lib/sport_ngin_aws_auditor/rds_instance.rb +4 -4
- data/lib/sport_ngin_aws_auditor/scripts/audit.rb +2 -2
- data/lib/sport_ngin_aws_auditor/version.rb +1 -1
- data/spec/sport_ngin_aws_auditor/cache_instance_spec.rb +1 -1
- data/spec/sport_ngin_aws_auditor/ec2_instance_spec.rb +33 -11
- data/spec/sport_ngin_aws_auditor/rds_instance_spec.rb +2 -2
- 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: 41d1decba10c84cc01e2651addad2e71c88aa467
|
4
|
+
data.tar.gz: 2a346488fc698a3ac5de44bd7a8e7e7f300d6d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a47cd28e41a0e7cb599d1c271dba4424951e607589f41ae991c46df5469ba2d1edcba86e08ba6d63aceef9d562bbdaee28e9d6bea0affb88815a075e4486abac
|
7
|
+
data.tar.gz: 30eeda03adf4d0d718a9df08706fe575693a0d9ccdc88bc6202be9daca0bca2e2a3295e7ebc594f50105fc4b1105511a95a503a87e4f8a87126dd470621212f4
|
data/CHANGELOG.markdown
CHANGED
@@ -1 +1,40 @@
|
|
1
|
+
#### v3.2.0
|
2
|
+
* Proper recognition of windows/linux/vpc instances
|
3
|
+
|
4
|
+
> Emma Sax: Andy Fleener: https://github.com/sportngin/sport_ngin_aws_auditor/pull/8
|
5
|
+
|
1
6
|
#### v3.1.2
|
7
|
+
#### v3.1.0
|
8
|
+
* Authentication with AWS roles instead of credentials file
|
9
|
+
|
10
|
+
> Emma Sax: Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/7
|
11
|
+
|
12
|
+
#### v3.0.2
|
13
|
+
#### v3.0.1
|
14
|
+
#### v3.0.0
|
15
|
+
* Rename gem directories and modules
|
16
|
+
|
17
|
+
> Emma Sax: Brian Bergstrom: https://github.com/sportngin/sport_ngin_aws_auditor/pull/6
|
18
|
+
|
19
|
+
#### v2.1.0
|
20
|
+
* Adding option to print audit results to Slack channel
|
21
|
+
|
22
|
+
> Emma Sax, Matt Krieger: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/4
|
23
|
+
|
24
|
+
* Adding option to print audit results to Slack channel
|
25
|
+
|
26
|
+
> Emma Sax, Matt Krieger: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/4
|
27
|
+
|
28
|
+
#### v2.0.0
|
29
|
+
* Adding enhancements for taking no-reserved-instance tag into consideration during audit
|
30
|
+
|
31
|
+
> Emma Sax: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/2
|
32
|
+
|
33
|
+
#### v1.0.0
|
34
|
+
* Upgrading aws-sdk version from v1 to v2
|
35
|
+
|
36
|
+
> Emma Sax: Brian Bergstrom: https://github.com/sportngin/aws_auditor/pull/3
|
37
|
+
|
38
|
+
* First tests, Travis CI, MFA support, and fog file compatibility
|
39
|
+
|
40
|
+
> Brian Bergstrom: Emma Sax: https://github.com/sportngin/aws_auditor/pull/1
|
@@ -14,7 +14,7 @@ module SportNginAwsAuditor
|
|
14
14
|
if ec2_instance.class.to_s == "Aws::EC2::Types::ReservedInstances"
|
15
15
|
self.id = ec2_instance.reserved_instances_id
|
16
16
|
self.name = nil
|
17
|
-
self.platform = platform_helper(ec2_instance)
|
17
|
+
self.platform = platform_helper(ec2_instance.product_description)
|
18
18
|
self.availability_zone = ec2_instance.availability_zone
|
19
19
|
self.instance_type = ec2_instance.instance_type
|
20
20
|
self.count = count
|
@@ -22,7 +22,7 @@ module SportNginAwsAuditor
|
|
22
22
|
elsif ec2_instance.class.to_s == "Aws::EC2::Types::Instance"
|
23
23
|
self.id = ec2_instance.instance_id
|
24
24
|
self.name = nil
|
25
|
-
self.platform = platform_helper(ec2_instance)
|
25
|
+
self.platform = platform_helper((ec2_instance.platform || ''), ec2_instance.vpc_id)
|
26
26
|
self.availability_zone = ec2_instance.placement.availability_zone
|
27
27
|
self.instance_type = ec2_instance.instance_type
|
28
28
|
self.count = count
|
@@ -66,28 +66,20 @@ module SportNginAwsAuditor
|
|
66
66
|
@tag_value
|
67
67
|
end
|
68
68
|
|
69
|
-
def platform_helper(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
return 'Linux'
|
81
|
-
end
|
82
|
-
elsif ec2_instance.class.to_s == "Aws::EC2::Types::ReservedInstances"
|
83
|
-
if ec2_instance.product_description.downcase.include? 'vpc'
|
84
|
-
return 'VPC'
|
85
|
-
elsif ec2_instance.product_description.downcase.include? 'windows'
|
86
|
-
return 'Windows'
|
87
|
-
else
|
88
|
-
return 'Linux'
|
89
|
-
end
|
69
|
+
def platform_helper(description, vpc=nil)
|
70
|
+
platform = ''
|
71
|
+
|
72
|
+
if description.downcase.include?('windows')
|
73
|
+
platform << 'Windows'
|
74
|
+
elsif description.downcase.include?('linux') || description.empty?
|
75
|
+
platform << 'Linux'
|
76
|
+
end
|
77
|
+
|
78
|
+
if description.downcase.include?('vpc') || vpc
|
79
|
+
platform << ' VPC'
|
90
80
|
end
|
81
|
+
|
82
|
+
return platform
|
91
83
|
end
|
92
84
|
private :platform_helper
|
93
85
|
|
@@ -16,13 +16,13 @@ module SportNginAwsAuditor
|
|
16
16
|
self.id = rds_instance.reserved_db_instances_offering_id
|
17
17
|
self.multi_az = rds_instance.multi_az ? "Multi-AZ" : "Single-AZ"
|
18
18
|
self.instance_type = rds_instance.db_instance_class
|
19
|
-
self.engine = rds_instance.product_description
|
19
|
+
self.engine = engine_helper(rds_instance.product_description)
|
20
20
|
self.count = 1
|
21
21
|
elsif rds_instance.class.to_s == "Aws::RDS::Types::DBInstance"
|
22
22
|
self.id = rds_instance.db_instance_identifier
|
23
23
|
self.multi_az = rds_instance.multi_az ? "Multi-AZ" : "Single-AZ"
|
24
24
|
self.instance_type = rds_instance.db_instance_class
|
25
|
-
self.engine = rds_instance.engine
|
25
|
+
self.engine = engine_helper(rds_instance.engine)
|
26
26
|
self.count = 1
|
27
27
|
|
28
28
|
if tag_name
|
@@ -41,7 +41,7 @@ module SportNginAwsAuditor
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def to_s
|
44
|
-
"#{
|
44
|
+
"#{engine} #{multi_az} #{instance_type}"
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.get_instances(tag_name=nil)
|
@@ -65,7 +65,7 @@ module SportNginAwsAuditor
|
|
65
65
|
@tag_value
|
66
66
|
end
|
67
67
|
|
68
|
-
def engine_helper
|
68
|
+
def engine_helper(engine)
|
69
69
|
if engine.downcase.include? "post"
|
70
70
|
return "PostgreSQL"
|
71
71
|
elsif engine.downcase.include? "mysql"
|
@@ -32,10 +32,10 @@ module SportNginAwsAuditor
|
|
32
32
|
print_data(slack, environment, data, "EC2Instance") if options[:ec2] || no_selection
|
33
33
|
|
34
34
|
data = gather_data("RDSInstance", tag_name) if options[:rds] || no_selection
|
35
|
-
print_data(slack, environment, data, "RDSInstance") if options[:
|
35
|
+
print_data(slack, environment, data, "RDSInstance") if options[:rds] || no_selection
|
36
36
|
|
37
37
|
data = gather_data("CacheInstance", tag_name) if options[:cache] || no_selection
|
38
|
-
print_data(slack, environment, data, "CacheInstance") if options[:
|
38
|
+
print_data(slack, environment, data, "CacheInstance") if options[:cache] || no_selection
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.gather_data(class_type, tag_name)
|
@@ -118,7 +118,7 @@ module SportNginAwsAuditor
|
|
118
118
|
allow(CacheInstance).to receive(:cache).and_return(cache_client)
|
119
119
|
instances = CacheInstance::get_instances("tag_name")
|
120
120
|
instance = instances.first
|
121
|
-
expect(instance.to_s).to eq("
|
121
|
+
expect(instance.to_s).to eq("Redis cache.t2.small")
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -26,7 +26,7 @@ module SportNginAwsAuditor
|
|
26
26
|
ec2_instance2 = double('ec2_instance', instance_id: "i-thisisfake",
|
27
27
|
instance_type: "t2.large",
|
28
28
|
vpc_id: "vpc-alsofake",
|
29
|
-
platform:
|
29
|
+
platform: "Windows",
|
30
30
|
state: state,
|
31
31
|
placement: placement,
|
32
32
|
tags: instance_tags,
|
@@ -36,7 +36,7 @@ module SportNginAwsAuditor
|
|
36
36
|
name_tag = { key: "Name", value: "our-app-instance-100" }
|
37
37
|
stack_tag = { key: "opsworks:stack", value: "our_app_service_2" }
|
38
38
|
client_tags = double('tags', tags: [name_tag, stack_tag])
|
39
|
-
ec2_client = double('
|
39
|
+
ec2_client = double('ec2_client', describe_instances: ec2_instances, describe_tags: client_tags)
|
40
40
|
allow(EC2Instance).to receive(:ec2).and_return(ec2_client)
|
41
41
|
end
|
42
42
|
|
@@ -60,7 +60,15 @@ module SportNginAwsAuditor
|
|
60
60
|
expect(instance.id).to eq("i-thisisfake")
|
61
61
|
expect(instance.availability_zone).to eq("us-east-1d")
|
62
62
|
expect(instance.instance_type).to eq("t2.large")
|
63
|
-
expect(instance.platform).to eq("VPC")
|
63
|
+
expect(instance.platform).to eq("Linux VPC")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should recognize Windows vs. Linux" do
|
67
|
+
instances = EC2Instance::get_instances("tag_name")
|
68
|
+
instance1 = instances.first
|
69
|
+
instance2 = instances.last
|
70
|
+
expect(instance1.platform).to eq("Linux VPC")
|
71
|
+
expect(instance2.platform).to eq("Windows VPC")
|
64
72
|
end
|
65
73
|
end
|
66
74
|
|
@@ -68,7 +76,7 @@ module SportNginAwsAuditor
|
|
68
76
|
before :each do
|
69
77
|
reserved_ec2_instance1 = double('reserved_ec2_instance', reserved_instances_id: "12345-dfas-1234-asdf-thisisfake!!",
|
70
78
|
instance_type: "t2.medium",
|
71
|
-
product_description: "
|
79
|
+
product_description: "Windows (Amazon VPC)",
|
72
80
|
state: "active",
|
73
81
|
availability_zone: "us-east-1b",
|
74
82
|
instance_count: 4,
|
@@ -81,7 +89,7 @@ module SportNginAwsAuditor
|
|
81
89
|
instance_count: 2,
|
82
90
|
class: "Aws::EC2::Types::ReservedInstances")
|
83
91
|
reserved_ec2_instances = double('reserved_ec2_instances', reserved_instances: [reserved_ec2_instance1, reserved_ec2_instance2])
|
84
|
-
ec2_client = double('
|
92
|
+
ec2_client = double('ec2_client', describe_reserved_instances: reserved_ec2_instances)
|
85
93
|
allow(EC2Instance).to receive(:ec2).and_return(ec2_client)
|
86
94
|
end
|
87
95
|
|
@@ -101,15 +109,23 @@ module SportNginAwsAuditor
|
|
101
109
|
reserved_instances = EC2Instance::get_reserved_instances
|
102
110
|
reserved_instance = reserved_instances.first
|
103
111
|
expect(reserved_instance.id).to eq("12345-dfas-1234-asdf-thisisfake!!")
|
104
|
-
expect(reserved_instance.platform).to eq("VPC")
|
112
|
+
expect(reserved_instance.platform).to eq("Windows VPC")
|
105
113
|
expect(reserved_instance.availability_zone).to eq("us-east-1b")
|
106
114
|
expect(reserved_instance.instance_type).to eq("t2.medium")
|
107
115
|
expect(reserved_instance.count).to eq(4)
|
108
116
|
end
|
117
|
+
|
118
|
+
it "should recognize Windows vs. Linux" do
|
119
|
+
reserved_instances = EC2Instance::get_reserved_instances
|
120
|
+
reserved_instance1 = reserved_instances.first
|
121
|
+
reserved_instance2 = reserved_instances.last
|
122
|
+
expect(reserved_instance1.platform).to eq("Windows VPC")
|
123
|
+
expect(reserved_instance2.platform).to eq("Linux VPC")
|
124
|
+
end
|
109
125
|
end
|
110
126
|
|
111
127
|
context "for returning pretty string formats" do
|
112
|
-
it "should return a string version of the name of the
|
128
|
+
it "should return a string version of the name of the reserved_ec2_instance" do
|
113
129
|
state = double('state', name: 'running')
|
114
130
|
placement = double('placement', availability_zone: "us-east-1d")
|
115
131
|
tag1 = double('tag', key: "cookie", value: "chocolate chip")
|
@@ -128,11 +144,11 @@ module SportNginAwsAuditor
|
|
128
144
|
name_tag = { key: "Name", value: "our-app-instance-100" }
|
129
145
|
stack_tag = { key: "opsworks:stack", value: "our_app_service_2" }
|
130
146
|
tags = double('tags', tags: [name_tag, stack_tag])
|
131
|
-
ec2_client = double('
|
147
|
+
ec2_client = double('ec2_client', describe_instances: ec2_instances, describe_tags: tags)
|
132
148
|
allow(EC2Instance).to receive(:ec2).and_return(ec2_client)
|
133
149
|
instances = EC2Instance::get_instances("tag_name")
|
134
150
|
instance = instances.first
|
135
|
-
expect(instance.to_s).to eq("VPC us-east-1d t2.large")
|
151
|
+
expect(instance.to_s).to eq("Linux VPC us-east-1d t2.large")
|
136
152
|
end
|
137
153
|
end
|
138
154
|
|
@@ -150,7 +166,7 @@ module SportNginAwsAuditor
|
|
150
166
|
ec2_instance2 = double('ec2_instance', instance_id: "i-alsofake",
|
151
167
|
instance_type: "t2.small",
|
152
168
|
vpc_id: "vpc-alsofake",
|
153
|
-
platform:
|
169
|
+
platform: "Windows",
|
154
170
|
state: state,
|
155
171
|
placement: placement,
|
156
172
|
class: "Aws::EC2::Types::Instance")
|
@@ -159,7 +175,7 @@ module SportNginAwsAuditor
|
|
159
175
|
name_tag = { key: "Name", value: "our-app-instance-100" }
|
160
176
|
stack_tag = { key: "opsworks:stack", value: "our_app_service_2" }
|
161
177
|
tags = double('tags', tags: [name_tag, stack_tag])
|
162
|
-
ec2_client = double('
|
178
|
+
ec2_client = double('ec2_client', describe_instances: ec2_instances, describe_tags: tags)
|
163
179
|
allow(EC2Instance).to receive(:ec2).and_return(ec2_client)
|
164
180
|
end
|
165
181
|
|
@@ -169,6 +185,12 @@ module SportNginAwsAuditor
|
|
169
185
|
expect(buckets.first.first).to eq("our_app_service_2")
|
170
186
|
end
|
171
187
|
|
188
|
+
it "should return a hash where the last element's key is the opsworks:stack name of the instances" do
|
189
|
+
instances = EC2Instance::get_instances
|
190
|
+
buckets = EC2Instance::bucketize
|
191
|
+
expect(buckets.last.first).to eq("our_app_service_2")
|
192
|
+
end
|
193
|
+
|
172
194
|
it "should return a hash where each element is a list of ec2_instances" do
|
173
195
|
instances = EC2Instance::get_instances
|
174
196
|
buckets = EC2Instance::bucketize
|
@@ -56,7 +56,7 @@ module SportNginAwsAuditor
|
|
56
56
|
expect(instance.id).to eq("our-service")
|
57
57
|
expect(instance.multi_az).to eq("Single-AZ")
|
58
58
|
expect(instance.instance_type).to eq("db.t2.small")
|
59
|
-
expect(instance.engine).to eq("
|
59
|
+
expect(instance.engine).to eq("MySQL")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -97,7 +97,7 @@ module SportNginAwsAuditor
|
|
97
97
|
expect(reserved_instance.id).to eq("555te4yy-1234-555c-5678-thisisafake!!")
|
98
98
|
expect(reserved_instance.multi_az).to eq("Single-AZ")
|
99
99
|
expect(reserved_instance.instance_type).to eq("db.t2.small")
|
100
|
-
expect(reserved_instance.engine).to eq("
|
100
|
+
expect(reserved_instance.engine).to eq("MySQL")
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
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.2.0
|
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-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|