aws-inventory 0.3.0 → 0.3.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: 5f5cff9d019cae6b629e6aa48890ea2aba7f665c
4
- data.tar.gz: a691ebdb60ecca8946b3419dcf4c21f702768f1f
3
+ metadata.gz: e6ff7b0b1ed3072711ce24784770a6f105f33107
4
+ data.tar.gz: b36139703667195d8b14c0fa2fc786e6006ec53b
5
5
  SHA512:
6
- metadata.gz: 1f9dea807fa8f915dc0db022954aff928b48cd699ce3e17f37961ceb8697010663ea074a9f17402f496871b82542b6ed5df814e56a6890e032bba2e7eda0e7b6
7
- data.tar.gz: 1390a1d93c1edd1316c4c5ebcaed648b56d0e9444a792cb64c4fdb61d4414dbfc324eaffcbba307ce1655eca947a177286f5881f201d850f0b2593196d9f83c9
6
+ metadata.gz: dcf16a41f945d6d3f11932ca9c2acd9584bb1ede6527e277728537f72923f7b1f410fa0828140741f5ef33ea47aae281a2b5d77600a200c8c0654d8655dbe3d8
7
+ data.tar.gz: eea11e513d1f9b8155d542d2da738de54f9a32e4498a60022d01b8d7a6777ce3ed2698cbd6b2272f61dc70a906b8011b3312c0d71794a26aa509d7971a18d0f2
@@ -3,5 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.3.1]
7
+ * add json presenter
8
+ * add unused security group report
9
+ * rename report-type option to report
10
+
6
11
  ## [0.3.0]
7
12
  - initial release
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aws-inventory (0.2.1)
4
+ aws-inventory (0.3.0)
5
5
  actionview
6
6
  activesupport
7
7
  aws-sdk
8
8
  colorize
9
9
  facets
10
10
  hashie
11
+ json
11
12
  text-table
12
13
  thor
13
14
 
@@ -25,7 +26,7 @@ GEM
25
26
  i18n (~> 0.7)
26
27
  minitest (~> 5.1)
27
28
  tzinfo (~> 1.1)
28
- aws-partitions (1.48.0)
29
+ aws-partitions (1.53.0)
29
30
  aws-sdk (3.0.1)
30
31
  aws-sdk-resources (~> 3)
31
32
  aws-sdk-acm (1.2.0)
@@ -34,7 +35,7 @@ GEM
34
35
  aws-sdk-alexaforbusiness (1.0.0)
35
36
  aws-sdk-core (~> 3)
36
37
  aws-sigv4 (~> 1.0)
37
- aws-sdk-apigateway (1.8.0)
38
+ aws-sdk-apigateway (1.9.0)
38
39
  aws-sdk-core (~> 3)
39
40
  aws-sigv4 (~> 1.0)
40
41
  aws-sdk-applicationautoscaling (1.6.0)
@@ -88,7 +89,7 @@ GEM
88
89
  aws-sdk-cloudtrail (1.0.0)
89
90
  aws-sdk-core (~> 3)
90
91
  aws-sigv4 (~> 1.0)
91
- aws-sdk-cloudwatch (1.3.0)
92
+ aws-sdk-cloudwatch (1.4.0)
92
93
  aws-sdk-core (~> 3)
93
94
  aws-sigv4 (~> 1.0)
94
95
  aws-sdk-cloudwatchevents (1.1.0)
@@ -97,7 +98,7 @@ GEM
97
98
  aws-sdk-cloudwatchlogs (1.2.0)
98
99
  aws-sdk-core (~> 3)
99
100
  aws-sigv4 (~> 1.0)
100
- aws-sdk-codebuild (1.4.0)
101
+ aws-sdk-codebuild (1.5.0)
101
102
  aws-sdk-core (~> 3)
102
103
  aws-sigv4 (~> 1.0)
103
104
  aws-sdk-codecommit (1.2.0)
@@ -124,10 +125,10 @@ GEM
124
125
  aws-sdk-comprehend (1.0.0)
125
126
  aws-sdk-core (~> 3)
126
127
  aws-sigv4 (~> 1.0)
127
- aws-sdk-configservice (1.4.0)
128
+ aws-sdk-configservice (1.5.0)
128
129
  aws-sdk-core (~> 3)
129
130
  aws-sigv4 (~> 1.0)
130
- aws-sdk-core (3.11.0)
131
+ aws-sdk-core (3.13.0)
131
132
  aws-partitions (~> 1.0)
132
133
  aws-sigv4 (~> 1.0)
133
134
  jmespath (~> 1.0)
@@ -161,13 +162,13 @@ GEM
161
162
  aws-sdk-dynamodbstreams (1.0.0)
162
163
  aws-sdk-core (~> 3)
163
164
  aws-sigv4 (~> 1.0)
164
- aws-sdk-ec2 (1.21.0)
165
+ aws-sdk-ec2 (1.24.0)
165
166
  aws-sdk-core (~> 3)
166
167
  aws-sigv4 (~> 1.0)
167
168
  aws-sdk-ecr (1.2.0)
168
169
  aws-sdk-core (~> 3)
169
170
  aws-sigv4 (~> 1.0)
170
- aws-sdk-ecs (1.7.0)
171
+ aws-sdk-ecs (1.8.0)
171
172
  aws-sdk-core (~> 3)
172
173
  aws-sigv4 (~> 1.0)
173
174
  aws-sdk-efs (1.0.0)
@@ -221,10 +222,10 @@ GEM
221
222
  aws-sdk-importexport (1.0.0)
222
223
  aws-sdk-core (~> 3)
223
224
  aws-sigv2 (~> 1.0)
224
- aws-sdk-inspector (1.1.0)
225
+ aws-sdk-inspector (1.2.0)
225
226
  aws-sdk-core (~> 3)
226
227
  aws-sigv4 (~> 1.0)
227
- aws-sdk-iot (1.2.0)
228
+ aws-sdk-iot (1.3.0)
228
229
  aws-sdk-core (~> 3)
229
230
  aws-sigv4 (~> 1.0)
230
231
  aws-sdk-iotdataplane (1.0.0)
@@ -236,7 +237,7 @@ GEM
236
237
  aws-sdk-kinesis (1.1.0)
237
238
  aws-sdk-core (~> 3)
238
239
  aws-sigv4 (~> 1.0)
239
- aws-sdk-kinesisanalytics (1.1.0)
240
+ aws-sdk-kinesisanalytics (1.2.0)
240
241
  aws-sdk-core (~> 3)
241
242
  aws-sigv4 (~> 1.0)
242
243
  aws-sdk-kinesisvideo (1.0.0)
@@ -290,7 +291,7 @@ GEM
290
291
  aws-sdk-mediastore (1.0.0)
291
292
  aws-sdk-core (~> 3)
292
293
  aws-sigv4 (~> 1.0)
293
- aws-sdk-mediastoredata (1.0.0)
294
+ aws-sdk-mediastoredata (1.1.0)
294
295
  aws-sdk-core (~> 3)
295
296
  aws-sigv4 (~> 1.0)
296
297
  aws-sdk-migrationhub (1.0.0)
@@ -468,7 +469,7 @@ GEM
468
469
  aws-sdk-workmail (~> 1)
469
470
  aws-sdk-workspaces (~> 1)
470
471
  aws-sdk-xray (~> 1)
471
- aws-sdk-route53 (1.5.0)
472
+ aws-sdk-route53 (1.6.0)
472
473
  aws-sdk-core (~> 3)
473
474
  aws-sigv4 (~> 1.0)
474
475
  aws-sdk-route53domains (1.1.0)
@@ -478,7 +479,7 @@ GEM
478
479
  aws-sdk-core (~> 3)
479
480
  aws-sdk-kms (~> 1)
480
481
  aws-sigv4 (~> 1.0)
481
- aws-sdk-sagemaker (1.3.0)
482
+ aws-sdk-sagemaker (1.4.0)
482
483
  aws-sdk-core (~> 3)
483
484
  aws-sigv4 (~> 1.0)
484
485
  aws-sdk-sagemakerruntime (1.0.0)
@@ -544,7 +545,7 @@ GEM
544
545
  aws-sdk-workmail (1.0.0)
545
546
  aws-sdk-core (~> 3)
546
547
  aws-sigv4 (~> 1.0)
547
- aws-sdk-workspaces (1.0.0)
548
+ aws-sdk-workspaces (1.1.0)
548
549
  aws-sdk-core (~> 3)
549
550
  aws-sigv4 (~> 1.0)
550
551
  aws-sdk-xray (1.1.0)
@@ -584,7 +585,7 @@ GEM
584
585
  guard (~> 2.1)
585
586
  guard-compat (~> 1.1)
586
587
  rspec (>= 2.99.0, < 4.0)
587
- hashie (3.5.6)
588
+ hashie (3.5.7)
588
589
  i18n (0.9.1)
589
590
  concurrent-ruby (~> 1.0)
590
591
  jmespath (1.3.1)
@@ -599,7 +600,7 @@ GEM
599
600
  lumberjack (1.0.12)
600
601
  method_source (0.9.0)
601
602
  mini_portile2 (2.3.0)
602
- minitest (5.10.3)
603
+ minitest (5.11.0)
603
604
  nenv (0.3.0)
604
605
  nokogiri (1.8.1)
605
606
  mini_portile2 (~> 2.3.0)
@@ -658,4 +659,4 @@ DEPENDENCIES
658
659
  rake
659
660
 
660
661
  BUNDLED WITH
661
- 1.16.0
662
+ 1.16.1
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Tung Nguyen
1
+ Copyright (c) 2017 Tung Nguyen
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # AWS Inventory
2
2
 
3
- AWS Inventory tool. Useful to get summarized information on AWS account. The tool by default produces a reoprt that can easily be read from a terminal, but it can also be used produce a tab separated output report that can be pasted into a spreadsheet and then copied to a report. This is controlled via a `AWS_INVENTORY_FORMAT` env variable and covered in the Format Options section.
3
+ AWS Inventory tool. Useful to get summarized information on AWS account. The tool by default produces a report that can easily be read from a terminal, but it can also be used produce a tab separated output report that can be pasted into a spreadsheet and then copied to a report. This is controlled via a `AWS_INVENTORY_FORMAT` env variable and covered in the Format Options section.
4
4
 
5
5
  ## Usage
6
-
7
6
  ```sh
8
7
  aws-inventory acm # report acm inventory
9
8
  aws-inventory cfn # report cfn inventory
@@ -49,17 +48,35 @@ GREEN='\033[0;32m'
49
48
  NC='\033[0m' # No Color
50
49
  for i in $(aws ec2 describe-regions | jq -r '.Regions[].RegionName') ; do
51
50
  echo -e "$GREEN$i$NC"
52
- AWS_REGION=$i inventory ec2
51
+ AWS_REGION=$i aws-inventory ec2
53
52
  done
54
53
  ```
55
54
 
56
55
  ### Format Option
57
56
 
58
- There are 2 supported formats: tab and table. The default is table. To switch between formats use the AWS_INVENTORY_FORMAT environment variable.
57
+ There are a few supported formats: tab, table and json. The default is table. To switch between formats use the AWS_INVENTORY_FORMAT environment variable.
59
58
 
60
59
  ```sh
61
60
  export AWS_INVENTORY_FORMAT=tab
62
61
  aws-inventory ec2
63
62
  export AWS_INVENTORY_FORMAT=table
64
63
  aws-inventory ec2
64
+ export AWS_INVENTORY_FORMAT=json
65
+ aws-inventory ec2
65
66
  ```
67
+
68
+ ## Install
69
+
70
+ ```sh
71
+ gem install aws-inventory
72
+ ```
73
+
74
+ ## Contributing
75
+
76
+ I love pull requests! Happy to answer questions to help.
77
+
78
+ 1. Fork it
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create new Pull Request
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "text-table"
28
28
  spec.add_dependency "facets"
29
29
  spec.add_dependency "actionview"
30
+ spec.add_dependency "json"
30
31
 
31
32
  spec.add_development_dependency "bundler"
32
33
  spec.add_development_dependency "byebug"
@@ -30,8 +30,8 @@ class Inventory::Base
30
30
  end
31
31
  end
32
32
 
33
- def show(report_type)
34
- ["all", report_type.to_s].include?(@options[:report_type])
33
+ def show(report)
34
+ ["all", report.to_s].include?(@options[:report])
35
35
  end
36
36
 
37
37
  class << self
@@ -62,10 +62,10 @@ class Inventory::Base
62
62
  class_name = path
63
63
  .sub('.rb','')
64
64
  .sub(%r{.*/inventory}, 'inventory')
65
- .sub('presenters', 'presenter') # special rule
66
65
  .camelize
67
66
  # special rules
68
67
  class_name.sub!("Cli", "CLI")
68
+ .sub!('Presenters', 'Presenter')
69
69
 
70
70
  class_name.constantize # use constantize instead of require
71
71
  # so we dont have to worry about require order.
@@ -22,14 +22,14 @@ module Inventory
22
22
 
23
23
  desc "sg", "report security group inventory"
24
24
  long_desc Help.text(:sg)
25
- option :report_type, default: "open", desc: "all, summary, or open"
25
+ option :report, default: "open", desc: "all, summary, open or unused"
26
26
  def sg
27
27
  SecurityGroup.new(options).report
28
28
  end
29
29
 
30
30
  desc "rds", "report rds inventory"
31
31
  long_desc Help.text(:rds)
32
- option :report_type, default: "summary", desc: "all, summary, or port"
32
+ option :report, default: "summary", desc: "all, summary, or port"
33
33
  def rds
34
34
  Rds.new(options).report
35
35
  end
@@ -72,7 +72,7 @@ module Inventory
72
72
 
73
73
  desc "iam", "report iam inventory"
74
74
  long_desc Help.text(:iam)
75
- option :report_type, default: "groups", desc: "all, groups, users, or summary"
75
+ option :report, default: "groups", desc: "all, groups, users, or summary"
76
76
  def iam
77
77
  Iam.new(options).report
78
78
  end
@@ -2,14 +2,14 @@ Reports the IAM inventory.
2
2
 
3
3
  List of groups and users in the groups:
4
4
 
5
- $ inventory iam --report-type groups # this is the default
5
+ $ inventory iam --report groups # this is the default
6
6
 
7
7
  $ inventory iam # same as above
8
8
 
9
9
  List of the users and their groups:
10
10
 
11
- $ inventory iam --report-type users
11
+ $ inventory iam --report users
12
12
 
13
13
  Summary of number of groups and users
14
14
 
15
- $ inventory iam --report-type summary
15
+ $ inventory iam --report summary
@@ -1,5 +1,5 @@
1
1
  Reports the RDS inventory
2
2
 
3
- $ inventory rds --report-type summary
3
+ $ inventory rds --report summary
4
4
 
5
- $ inventory rds --report-type port
5
+ $ inventory rds --report port
@@ -2,6 +2,7 @@ class Inventory::Presenter
2
2
  autoload :Base, "inventory/presenters/base"
3
3
  autoload :Tab, "inventory/presenters/tab"
4
4
  autoload :Table, "inventory/presenters/table"
5
+ autoload :Json, "inventory/presenters/json"
5
6
 
6
7
  def initialize(data)
7
8
  @data = data
@@ -0,0 +1,11 @@
1
+ require "json"
2
+
3
+ class Inventory::Presenter::Json < Inventory::Presenter::Base
4
+ def display
5
+ json_data = {
6
+ header: @data.shift,
7
+ data: @data
8
+ }
9
+ puts JSON.dump(json_data)
10
+ end
11
+ end
@@ -2,10 +2,12 @@ class Inventory::SecurityGroup < Inventory::Base
2
2
  autoload :Shared, "inventory/security_group/shared"
3
3
  autoload :Summary, "inventory/security_group/summary"
4
4
  autoload :Open, "inventory/security_group/open"
5
+ autoload :Unused, "inventory/security_group/unused"
5
6
 
6
7
  # Default is the open report because it seems like the most useful report
7
8
  def report
8
9
  Summary.new(@options).report if show(:summary)
9
10
  Open.new(@options).report if show(:open)
11
+ Unused.new(@options.report).report if show(:unused)
10
12
  end
11
13
  end
@@ -0,0 +1,15 @@
1
+ class Inventory::SecurityGroup
2
+ class Unused < Inventory::Base
3
+ include Shared
4
+
5
+ def header
6
+ ["Security Group Name"]
7
+ end
8
+
9
+ def data
10
+ used_security_groups.map do |sg|
11
+ sg.group_name
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Inventory
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-inventory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2018-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -260,6 +274,7 @@ files:
260
274
  - lib/inventory/keypair.rb
261
275
  - lib/inventory/presenter.rb
262
276
  - lib/inventory/presenters/base.rb
277
+ - lib/inventory/presenters/json.rb
263
278
  - lib/inventory/presenters/tab.rb
264
279
  - lib/inventory/presenters/table.rb
265
280
  - lib/inventory/rds.rb
@@ -271,6 +286,7 @@ files:
271
286
  - lib/inventory/security_group/open.rb
272
287
  - lib/inventory/security_group/shared.rb
273
288
  - lib/inventory/security_group/summary.rb
289
+ - lib/inventory/security_group/unused.rb
274
290
  - lib/inventory/shared.rb
275
291
  - lib/inventory/version.rb
276
292
  - lib/inventory/vpc.rb
@@ -298,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
314
  version: '0'
299
315
  requirements: []
300
316
  rubyforge_project:
301
- rubygems_version: 2.6.13
317
+ rubygems_version: 2.6.14
302
318
  signing_key:
303
319
  specification_version: 4
304
320
  summary: Tool to inventory AWS account