aws-inventory 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +1 -1
  5. data/README.md +2 -2
  6. data/{inventory.gemspec → aws_inventory.gemspec} +2 -2
  7. data/exe/aws-inventory +3 -3
  8. data/lib/aws_inventory.rb +27 -0
  9. data/lib/{inventory → aws_inventory}/acm.rb +1 -1
  10. data/lib/{inventory → aws_inventory}/aws_services.rb +2 -2
  11. data/lib/{inventory → aws_inventory}/base.rb +6 -6
  12. data/lib/{inventory → aws_inventory}/cfn.rb +1 -1
  13. data/lib/{inventory → aws_inventory}/cli.rb +2 -1
  14. data/lib/{inventory → aws_inventory}/cloudwatch.rb +1 -1
  15. data/lib/{inventory → aws_inventory}/command.rb +6 -6
  16. data/lib/{inventory → aws_inventory}/eb.rb +1 -1
  17. data/lib/{inventory → aws_inventory}/ec2.rb +1 -1
  18. data/lib/aws_inventory/ecs.rb +10 -0
  19. data/lib/{inventory → aws_inventory}/ecs/cluster.rb +1 -1
  20. data/lib/{inventory → aws_inventory}/ecs/service.rb +1 -1
  21. data/lib/{inventory → aws_inventory}/elb.rb +4 -4
  22. data/lib/{inventory → aws_inventory}/help.rb +1 -1
  23. data/lib/{inventory → aws_inventory}/help/acm.md +0 -0
  24. data/lib/{inventory → aws_inventory}/help/cfn.md +0 -0
  25. data/lib/{inventory → aws_inventory}/help/cw.md +0 -0
  26. data/lib/{inventory → aws_inventory}/help/eb.md +0 -0
  27. data/lib/{inventory → aws_inventory}/help/ec2.md +0 -0
  28. data/lib/{inventory → aws_inventory}/help/ecs.md +0 -0
  29. data/lib/{inventory → aws_inventory}/help/elb.md +0 -0
  30. data/lib/aws_inventory/help/iam.md +15 -0
  31. data/lib/{inventory → aws_inventory}/help/keypair.md +0 -0
  32. data/lib/aws_inventory/help/rds.md +5 -0
  33. data/lib/{inventory → aws_inventory}/help/sg.md +0 -0
  34. data/lib/{inventory → aws_inventory}/help/vpc.md +0 -0
  35. data/lib/{inventory → aws_inventory}/iam.rb +5 -5
  36. data/lib/{inventory → aws_inventory}/iam/group.rb +2 -2
  37. data/lib/{inventory → aws_inventory}/iam/shared.rb +1 -1
  38. data/lib/{inventory → aws_inventory}/iam/summary.rb +2 -2
  39. data/lib/{inventory → aws_inventory}/iam/user.rb +2 -2
  40. data/lib/{inventory → aws_inventory}/keypair.rb +1 -1
  41. data/lib/aws_inventory/presenter.rb +22 -0
  42. data/lib/aws_inventory/presenters/base.rb +10 -0
  43. data/lib/aws_inventory/presenters/json.rb +11 -0
  44. data/lib/aws_inventory/presenters/tab.rb +7 -0
  45. data/lib/aws_inventory/presenters/table.rb +10 -0
  46. data/lib/{inventory → aws_inventory}/rds.rb +4 -4
  47. data/lib/{inventory → aws_inventory}/rds/port.rb +2 -2
  48. data/lib/{inventory → aws_inventory}/rds/shared.rb +3 -3
  49. data/lib/{inventory → aws_inventory}/rds/summary.rb +2 -2
  50. data/lib/{inventory → aws_inventory}/route53.rb +1 -1
  51. data/lib/aws_inventory/security_group.rb +13 -0
  52. data/lib/{inventory → aws_inventory}/security_group/open.rb +2 -2
  53. data/lib/{inventory → aws_inventory}/security_group/shared.rb +1 -1
  54. data/lib/{inventory → aws_inventory}/security_group/summary.rb +2 -2
  55. data/lib/{inventory → aws_inventory}/security_group/unused.rb +2 -2
  56. data/lib/{inventory → aws_inventory}/shared.rb +1 -1
  57. data/lib/aws_inventory/version.rb +3 -0
  58. data/lib/{inventory → aws_inventory}/vpc.rb +1 -1
  59. data/spec/lib/aws_inventory/base_spec.rb +7 -0
  60. data/spec/lib/{inventory → aws_inventory}/security_group/open_spec.rb +2 -2
  61. data/spec/lib/cli_spec.rb +1 -1
  62. data/spec/spec_helper.rb +1 -1
  63. metadata +58 -58
  64. data/lib/inventory.rb +0 -27
  65. data/lib/inventory/ecs.rb +0 -10
  66. data/lib/inventory/help/iam.md +0 -15
  67. data/lib/inventory/help/rds.md +0 -5
  68. data/lib/inventory/presenter.rb +0 -21
  69. data/lib/inventory/presenters/base.rb +0 -5
  70. data/lib/inventory/presenters/json.rb +0 -11
  71. data/lib/inventory/presenters/tab.rb +0 -7
  72. data/lib/inventory/presenters/table.rb +0 -10
  73. data/lib/inventory/security_group.rb +0 -13
  74. data/lib/inventory/version.rb +0 -3
  75. data/spec/lib/inventory/base_spec.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56114355825607b44e16c18622cc14ebd3299125
4
- data.tar.gz: ca791b7049a3730a48a78c564f81e6c504a98478
3
+ metadata.gz: 499ffb69b91d22febfa998f60dbcae85addfb9f8
4
+ data.tar.gz: 2a834b23c194b0dddbaa45c7192aea4e5d3fb014
5
5
  SHA512:
6
- metadata.gz: 6e6937bb56c6932800a12e0743b8e754ebfdbcf56244555a609c8927c18afb8ff42cfdca1ff68147ba7c1aa7035a2e55a47671ab3302839e56c6d52babfe2f24
7
- data.tar.gz: 876c43d029a48afef75847e3306a987a0fd7c01f6c8bdc1384b1b39f761cb771cc24380c78aa6f0e2da337d1540f10b0c1c10fbff1b3c1d4aa2a7a635379615f
6
+ metadata.gz: 53a9f593124dc37d879df905fbca16c3cffcf73e5fe1d26dd757bb48b92e65523b6213711d7017b36bcfe2f3f4dbf92fa6266db7fb280fa1e5c3d84c95d9630b
7
+ data.tar.gz: f100bc493a36ece7b2ba49039fcd2313de01616f028d71778028187b19472208e734f470df6e720facdea743b6da36c25f4d1fa027ae66dfcf0cbe25181c31ed
@@ -3,6 +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.4.0]
7
+ * rename Inventory module to AwsInventory
8
+ * add --no-header support
9
+
6
10
  ## [0.3.2]
7
11
  * fix unused security group report
8
12
 
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem dependencies in inventory.gemspec
3
+ # Specify your gem dependencies in aws_inventory.gemspec
4
4
  gemspec
5
5
 
6
6
  gem "codeclimate-test-reporter", group: :test, require: nil
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aws-inventory (0.3.0)
4
+ aws-inventory (0.3.2)
5
5
  actionview
6
6
  activesupport
7
7
  aws-sdk
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # AWS Inventory
1
+ # AWS AwsInventory
2
2
 
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.
3
+ AWS AwsInventory 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
6
  ```sh
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "inventory/version"
4
+ require "aws_inventory/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "aws-inventory"
8
- spec.version = Inventory::VERSION
8
+ spec.version = AwsInventory::VERSION
9
9
  spec.authors = ["Tung Nguyen"]
10
10
  spec.email = ["tongueroo@gmail.com"]
11
11
  spec.description = %q{Tool to inventory AWS account}
@@ -8,7 +8,7 @@ Signal.trap("INT") {
8
8
  }
9
9
 
10
10
  $:.unshift(File.expand_path("../../lib", __FILE__))
11
- require "inventory"
12
- require "inventory/cli"
11
+ require "aws_inventory"
12
+ require "aws_inventory/cli"
13
13
 
14
- Inventory::CLI.start(ARGV)
14
+ AwsInventory::CLI.start(ARGV)
@@ -0,0 +1,27 @@
1
+ $:.unshift(File.expand_path("../", __FILE__))
2
+ require "aws_inventory/version"
3
+ require "text-table"
4
+ require "active_support/all"
5
+
6
+ module AwsInventory
7
+ autoload :Base, "aws_inventory/base"
8
+ autoload :Help, "aws_inventory/help"
9
+ autoload :Command, "aws_inventory/command"
10
+ autoload :CLI, "aws_inventory/cli"
11
+ autoload :AwsServices, "aws_inventory/aws_services"
12
+ autoload :Shared, "aws_inventory/shared"
13
+ autoload :Presenter, "aws_inventory/presenter"
14
+ autoload :Cfn, "aws_inventory/cfn"
15
+ autoload :Ec2, "aws_inventory/ec2"
16
+ autoload :Vpc, "aws_inventory/vpc"
17
+ autoload :SecurityGroup, "aws_inventory/security_group"
18
+ autoload :Rds, "aws_inventory/rds"
19
+ autoload :Route53, "aws_inventory/route53"
20
+ autoload :Acm, "aws_inventory/acm"
21
+ autoload :Elb, "aws_inventory/elb"
22
+ autoload :Eb, "aws_inventory/eb"
23
+ autoload :Ecs, "aws_inventory/ecs"
24
+ autoload :Keypair, "aws_inventory/keypair"
25
+ autoload :Iam, "aws_inventory/iam"
26
+ autoload :Cloudwatch, "aws_inventory/cloudwatch"
27
+ end
@@ -1,4 +1,4 @@
1
- class Inventory::Acm < Inventory::Base
1
+ class AwsInventory::Acm < AwsInventory::Base
2
2
  def header
3
3
  ["Domain", "Cert Arn"]
4
4
  end
@@ -1,7 +1,7 @@
1
1
  require 'aws-sdk'
2
2
 
3
- module Inventory::AwsServices
4
- include Inventory::Shared
3
+ module AwsInventory::AwsServices
4
+ include AwsInventory::Shared
5
5
 
6
6
  def cfn
7
7
  @cfn ||= Aws::CloudFormation::Client.new
@@ -3,8 +3,8 @@
3
3
  # header - header row to display. Array of strings.
4
4
  # data - data to display under header. 2D Array.
5
5
  # Each item in the array represents a row of data.
6
- class Inventory::Base
7
- include Inventory::AwsServices
6
+ class AwsInventory::Base
7
+ include AwsInventory::AwsServices
8
8
 
9
9
  def initialize(options)
10
10
  @options = options
@@ -15,7 +15,7 @@ class Inventory::Base
15
15
 
16
16
  results = sort(data)
17
17
  results.unshift(header) if header
18
- presenter = Inventory::Presenter.new(results)
18
+ presenter = AwsInventory::Presenter.new(@options, results)
19
19
  presenter.display
20
20
  end
21
21
 
@@ -61,11 +61,11 @@ class Inventory::Base
61
61
 
62
62
  class_name = path
63
63
  .sub('.rb','')
64
- .sub(%r{.*/inventory}, 'inventory')
64
+ .sub(%r{.*/aws_inventory}, 'aws_inventory')
65
65
  .camelize
66
66
  # special rules
67
- class_name.sub!("Cli", "CLI")
68
- .sub!('Presenters', 'Presenter')
67
+ class_name = 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.
@@ -1,4 +1,4 @@
1
- class Inventory::Cfn < Inventory::Base
1
+ class AwsInventory::Cfn < AwsInventory::Base
2
2
  ALL_STATUSES = %w[
3
3
  REVIEW_IN_PROGRESS
4
4
  CREATE_FAILED
@@ -1,6 +1,7 @@
1
- module Inventory
1
+ module AwsInventory
2
2
  class CLI < Command
3
3
  class_option :verbose, type: :boolean
4
+ class_option :header, default: true, type: :boolean
4
5
 
5
6
  desc "cfn", "report cfn inventory"
6
7
  long_desc Help.text(:cfn)
@@ -1,6 +1,6 @@
1
1
  require "action_view"
2
2
 
3
- class Inventory::Cloudwatch < Inventory::Base
3
+ class AwsInventory::Cloudwatch < AwsInventory::Base
4
4
  include ActionView::Helpers::DateHelper
5
5
 
6
6
  def header
@@ -1,18 +1,18 @@
1
1
  require "thor"
2
2
 
3
- module Inventory
3
+ module AwsInventory
4
4
  class Command < Thor
5
5
  class << self
6
6
  def dispatch(m, args, options, config)
7
7
  # Allow calling for help via:
8
- # inventory command help
9
- # inventory command -h
10
- # inventory command --help
11
- # inventory command -D
8
+ # aws-inventory command help
9
+ # aws-inventory command -h
10
+ # aws-inventory command --help
11
+ # aws-inventory command -D
12
12
  #
13
13
  # as well thor's normal way:
14
14
  #
15
- # inventory help command
15
+ # aws-inventory help command
16
16
  help_flags = Thor::HELP_MAPPINGS + ["help"]
17
17
  if args.length > 1 && !(args & help_flags).empty?
18
18
  args -= help_flags
@@ -1,4 +1,4 @@
1
- class Inventory::Eb < Inventory::Base
1
+ class AwsInventory::Eb < AwsInventory::Base
2
2
  def header
3
3
  ["Environment", "Application", "Solution Stack"]
4
4
  end
@@ -1,4 +1,4 @@
1
- class Inventory::Ec2 < Inventory::Base
1
+ class AwsInventory::Ec2 < AwsInventory::Base
2
2
  def header
3
3
  ["Name", "Instance Id", "Instance Type", "Platform", "Security Groups"]
4
4
  end
@@ -0,0 +1,10 @@
1
+ class AwsInventory::Ecs < AwsInventory::Base
2
+ autoload :Service, "aws_inventory/ecs/service"
3
+ autoload :Cluster, "aws_inventory/ecs/cluster"
4
+
5
+ # Override report
6
+ def report
7
+ Service.new(@options).report
8
+ Cluster.new(@options).report
9
+ end
10
+ end
@@ -1,4 +1,4 @@
1
- class Inventory::Ecs::Cluster < Inventory::Base
1
+ class AwsInventory::Ecs::Cluster < AwsInventory::Base
2
2
  def header
3
3
  ["Cluster", "Container Instances", "Running Tasks"]
4
4
  end
@@ -1,4 +1,4 @@
1
- class Inventory::Ecs::Service < Inventory::Base
1
+ class AwsInventory::Ecs::Service < AwsInventory::Base
2
2
  def header
3
3
  ["Service", "Cluster", "Running Tasks"]
4
4
  end
@@ -1,4 +1,4 @@
1
- class Inventory::Elb < Inventory::Base
1
+ class AwsInventory::Elb < AwsInventory::Base
2
2
  def header
3
3
  ["ELB", "Type", "Security Group", "Open Ports"]
4
4
  end
@@ -60,12 +60,12 @@ class Inventory::Elb < Inventory::Base
60
60
  end
61
61
 
62
62
  # Returns an Array of ports with a cidr of 0.0.0.0/0
63
- # Delegates to Inventory::SecurityGroup
63
+ # Delegates to AwsInventory::SecurityGroup
64
64
  def open_ports(group_id)
65
65
  sg = security_groups.find { |sg| sg.group_id == group_id }
66
66
  return unless sg
67
67
 
68
- inventory = Inventory::SecurityGroup::Open.new(@options)
69
- inventory.ports_open_to_world(sg)
68
+ aws_inventory = AwsInventory::SecurityGroup::Open.new(@options)
69
+ aws_inventory.ports_open_to_world(sg)
70
70
  end
71
71
  end
@@ -1,4 +1,4 @@
1
- module Inventory::Help
1
+ module AwsInventory::Help
2
2
  class << self
3
3
  def text(namespaced_command)
4
4
  path = namespaced_command.to_s.gsub(':','/')
@@ -0,0 +1,15 @@
1
+ Reports the IAM inventory.
2
+
3
+ List of groups and users in the groups:
4
+
5
+ $ aws-inventory iam --report groups # this is the default
6
+
7
+ $ aws-inventory iam # same as above
8
+
9
+ List of the users and their groups:
10
+
11
+ $ aws-inventory iam --report users
12
+
13
+ Summary of number of groups and users
14
+
15
+ $ aws-inventory iam --report summary
@@ -0,0 +1,5 @@
1
+ Reports the RDS inventory
2
+
3
+ $ aws-inventory rds --report summary
4
+
5
+ $ aws-inventory rds --report port
@@ -1,8 +1,8 @@
1
- class Inventory::Iam < Inventory::Base
2
- autoload :Shared, "inventory/iam/shared"
3
- autoload :Summary, "inventory/iam/summary"
4
- autoload :User, "inventory/iam/user"
5
- autoload :Group, "inventory/iam/group"
1
+ class AwsInventory::Iam < AwsInventory::Base
2
+ autoload :Shared, "aws_inventory/iam/shared"
3
+ autoload :Summary, "aws_inventory/iam/summary"
4
+ autoload :User, "aws_inventory/iam/user"
5
+ autoload :Group, "aws_inventory/iam/group"
6
6
 
7
7
  # Default is the groups report because it seems like the most useful report
8
8
  def report
@@ -1,5 +1,5 @@
1
- class Inventory::Iam
2
- class Group < Inventory::Base
1
+ class AwsInventory::Iam
2
+ class Group < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,4 +1,4 @@
1
- module Inventory::Iam::Shared
1
+ module AwsInventory::Iam::Shared
2
2
  def group_names(user)
3
3
  groups = groups_for(user)
4
4
  groups.map(&:group_name)
@@ -1,5 +1,5 @@
1
- class Inventory::Iam
2
- class Summary < Inventory::Base
1
+ class AwsInventory::Iam
2
+ class Summary < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,5 +1,5 @@
1
- class Inventory::Iam
2
- class User < Inventory::Base
1
+ class AwsInventory::Iam
2
+ class User < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,4 +1,4 @@
1
- class Inventory::Keypair < Inventory::Base
1
+ class AwsInventory::Keypair < AwsInventory::Base
2
2
  def header
3
3
  ["Key Name", "Instance Count"]
4
4
  end
@@ -0,0 +1,22 @@
1
+ class AwsInventory::Presenter
2
+ autoload :Base, "aws_inventory/presenters/base"
3
+ autoload :Tab, "aws_inventory/presenters/tab"
4
+ autoload :Table, "aws_inventory/presenters/table"
5
+ autoload :Json, "aws_inventory/presenters/json"
6
+
7
+ def initialize(options, data)
8
+ @options = options
9
+ @data = data
10
+ end
11
+
12
+ def display
13
+ presenter_class = "AwsInventory::Presenter::#{format.classify}".constantize
14
+ presenter = presenter_class.new(@options, @data)
15
+ presenter.display
16
+ end
17
+
18
+ # Formats: tabs, markdown
19
+ def format
20
+ ENV['AWS_INVENTORY_FORMAT'] || "table"
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ class AwsInventory::Presenter::Base
2
+ def initialize(options, data)
3
+ @options = options
4
+ @data = data
5
+ end
6
+
7
+ def data
8
+ @options[:header] ? @data : @data[1..-1] # remove the header row
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require "json"
2
+
3
+ class AwsInventory::Presenter::Json < AwsInventory::Presenter::Base
4
+ def display
5
+ json_data = {
6
+ header: data.shift,
7
+ data: data
8
+ }
9
+ puts JSON.pretty_generate(json_data)
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ class AwsInventory::Presenter::Tab < AwsInventory::Presenter::Base
2
+ def display
3
+ data.each do |row|
4
+ puts row.join("\t")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'text-table'
2
+
3
+ class AwsInventory::Presenter::Table < AwsInventory::Presenter::Base
4
+ def display
5
+ table = Text::Table.new
6
+ table.head = data.shift
7
+ table.rows = data
8
+ puts table
9
+ end
10
+ end
@@ -1,7 +1,7 @@
1
- class Inventory::Rds < Inventory::Base
2
- autoload :Shared, "inventory/rds/shared"
3
- autoload :Summary, "inventory/rds/summary"
4
- autoload :Port, "inventory/rds/port"
1
+ class AwsInventory::Rds < AwsInventory::Base
2
+ autoload :Shared, "aws_inventory/rds/shared"
3
+ autoload :Summary, "aws_inventory/rds/summary"
4
+ autoload :Port, "aws_inventory/rds/port"
5
5
 
6
6
  # Default is the open report because it seems like the most useful report
7
7
  def report
@@ -1,5 +1,5 @@
1
- class Inventory::Rds
2
- class Port < Inventory::Base
1
+ class AwsInventory::Rds
2
+ class Port < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,4 +1,4 @@
1
- module Inventory::Rds::Shared
1
+ module AwsInventory::Rds::Shared
2
2
  # pretty name of vpc
3
3
  def vpc_name(db)
4
4
  group_ids = db.vpc_security_groups.map(&:vpc_security_group_id)
@@ -12,8 +12,8 @@ module Inventory::Rds::Shared
12
12
  end
13
13
 
14
14
  def lookup_vpc_name(vpc_id)
15
- inventory_vpc = Inventory::Vpc.new(@options)
16
- inventory_vpc.vpc_name(vpc_id)
15
+ aws_inventory_vpc = AwsInventory::Vpc.new(@options)
16
+ aws_inventory_vpc.vpc_name(vpc_id)
17
17
  end
18
18
 
19
19
  def vpcs
@@ -1,5 +1,5 @@
1
- class Inventory::Rds
2
- class Summary < Inventory::Base
1
+ class AwsInventory::Rds
2
+ class Summary < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,4 +1,4 @@
1
- class Inventory::Route53 < Inventory::Base
1
+ class AwsInventory::Route53 < AwsInventory::Base
2
2
  def header
3
3
  ["Domain", "Record Set Count"]
4
4
  end
@@ -0,0 +1,13 @@
1
+ class AwsInventory::SecurityGroup < AwsInventory::Base
2
+ autoload :Shared, "aws_inventory/security_group/shared"
3
+ autoload :Summary, "aws_inventory/security_group/summary"
4
+ autoload :Open, "aws_inventory/security_group/open"
5
+ autoload :Unused, "aws_inventory/security_group/unused"
6
+
7
+ # Default is the open report because it seems like the most useful report
8
+ def report
9
+ Summary.new(@options).report if show(:summary)
10
+ Open.new(@options).report if show(:open)
11
+ Unused.new(@options).report if show(:unused)
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
1
  require 'facets/array/arrange'
2
2
 
3
- class Inventory::SecurityGroup
4
- class Open < Inventory::Base
3
+ class AwsInventory::SecurityGroup
4
+ class Open < AwsInventory::Base
5
5
  include Shared
6
6
 
7
7
  def header
@@ -1,4 +1,4 @@
1
- module Inventory::SecurityGroup::Shared
1
+ module AwsInventory::SecurityGroup::Shared
2
2
  def used_security_groups
3
3
  groups = instances.inject([]) do |results, i|
4
4
  results += i.security_groups
@@ -1,5 +1,5 @@
1
- class Inventory::SecurityGroup
2
- class Summary < Inventory::Base
1
+ class AwsInventory::SecurityGroup
2
+ class Summary < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,5 +1,5 @@
1
- class Inventory::SecurityGroup
2
- class Unused < Inventory::Base
1
+ class AwsInventory::SecurityGroup
2
+ class Unused < AwsInventory::Base
3
3
  include Shared
4
4
 
5
5
  def header
@@ -1,4 +1,4 @@
1
- module Inventory::Shared
1
+ module AwsInventory::Shared
2
2
  def instances
3
3
  return @instances if @instances
4
4
 
@@ -0,0 +1,3 @@
1
+ module AwsInventory
2
+ VERSION = "0.4.0"
3
+ end
@@ -1,4 +1,4 @@
1
- class Inventory::Vpc < Inventory::Base
1
+ class AwsInventory::Vpc < AwsInventory::Base
2
2
  def header
3
3
  ["Name", "Vpc ID", "CIDR", "Subnets", "Instances"]
4
4
  end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe AwsInventory::Base do
4
+ it "eager_load!" do
5
+ AwsInventory::Base.eager_load!
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Inventory::SecurityGroup::Open do
4
- let(:reporter) { Inventory::SecurityGroup::Open.new({}) }
3
+ describe AwsInventory::SecurityGroup::Open do
4
+ let(:reporter) { AwsInventory::SecurityGroup::Open.new({}) }
5
5
 
6
6
  it "combine_ports" do
7
7
  ports = [22]
@@ -5,7 +5,7 @@ require "spec_helper"
5
5
  #
6
6
  # to run specs with new fresh data from aws api calls
7
7
  # $ rake clean:vcr ; time rake
8
- describe Inventory::CLI do
8
+ describe AwsInventory::CLI do
9
9
  before(:all) do
10
10
  @args = ""
11
11
  end
@@ -8,7 +8,7 @@ ENV['HOME'] = "spec/fixtures/home"
8
8
  require "pp"
9
9
 
10
10
  root = File.expand_path("../../", __FILE__)
11
- require "#{root}/lib/inventory"
11
+ require "#{root}/lib/aws_inventory"
12
12
 
13
13
  module Helpers
14
14
  def execute(cmd)
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.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-02 00:00:00.000000000 Z
11
+ date: 2018-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -237,62 +237,62 @@ files:
237
237
  - LICENSE.txt
238
238
  - README.md
239
239
  - Rakefile
240
+ - aws_inventory.gemspec
240
241
  - exe/aws-inventory
241
- - inventory.gemspec
242
- - lib/inventory.rb
243
- - lib/inventory/acm.rb
244
- - lib/inventory/aws_services.rb
245
- - lib/inventory/base.rb
246
- - lib/inventory/cfn.rb
247
- - lib/inventory/cli.rb
248
- - lib/inventory/cloudwatch.rb
249
- - lib/inventory/command.rb
250
- - lib/inventory/eb.rb
251
- - lib/inventory/ec2.rb
252
- - lib/inventory/ecs.rb
253
- - lib/inventory/ecs/cluster.rb
254
- - lib/inventory/ecs/service.rb
255
- - lib/inventory/elb.rb
256
- - lib/inventory/help.rb
257
- - lib/inventory/help/acm.md
258
- - lib/inventory/help/cfn.md
259
- - lib/inventory/help/cw.md
260
- - lib/inventory/help/eb.md
261
- - lib/inventory/help/ec2.md
262
- - lib/inventory/help/ecs.md
263
- - lib/inventory/help/elb.md
264
- - lib/inventory/help/iam.md
265
- - lib/inventory/help/keypair.md
266
- - lib/inventory/help/rds.md
267
- - lib/inventory/help/sg.md
268
- - lib/inventory/help/vpc.md
269
- - lib/inventory/iam.rb
270
- - lib/inventory/iam/group.rb
271
- - lib/inventory/iam/shared.rb
272
- - lib/inventory/iam/summary.rb
273
- - lib/inventory/iam/user.rb
274
- - lib/inventory/keypair.rb
275
- - lib/inventory/presenter.rb
276
- - lib/inventory/presenters/base.rb
277
- - lib/inventory/presenters/json.rb
278
- - lib/inventory/presenters/tab.rb
279
- - lib/inventory/presenters/table.rb
280
- - lib/inventory/rds.rb
281
- - lib/inventory/rds/port.rb
282
- - lib/inventory/rds/shared.rb
283
- - lib/inventory/rds/summary.rb
284
- - lib/inventory/route53.rb
285
- - lib/inventory/security_group.rb
286
- - lib/inventory/security_group/open.rb
287
- - lib/inventory/security_group/shared.rb
288
- - lib/inventory/security_group/summary.rb
289
- - lib/inventory/security_group/unused.rb
290
- - lib/inventory/shared.rb
291
- - lib/inventory/version.rb
292
- - lib/inventory/vpc.rb
242
+ - lib/aws_inventory.rb
243
+ - lib/aws_inventory/acm.rb
244
+ - lib/aws_inventory/aws_services.rb
245
+ - lib/aws_inventory/base.rb
246
+ - lib/aws_inventory/cfn.rb
247
+ - lib/aws_inventory/cli.rb
248
+ - lib/aws_inventory/cloudwatch.rb
249
+ - lib/aws_inventory/command.rb
250
+ - lib/aws_inventory/eb.rb
251
+ - lib/aws_inventory/ec2.rb
252
+ - lib/aws_inventory/ecs.rb
253
+ - lib/aws_inventory/ecs/cluster.rb
254
+ - lib/aws_inventory/ecs/service.rb
255
+ - lib/aws_inventory/elb.rb
256
+ - lib/aws_inventory/help.rb
257
+ - lib/aws_inventory/help/acm.md
258
+ - lib/aws_inventory/help/cfn.md
259
+ - lib/aws_inventory/help/cw.md
260
+ - lib/aws_inventory/help/eb.md
261
+ - lib/aws_inventory/help/ec2.md
262
+ - lib/aws_inventory/help/ecs.md
263
+ - lib/aws_inventory/help/elb.md
264
+ - lib/aws_inventory/help/iam.md
265
+ - lib/aws_inventory/help/keypair.md
266
+ - lib/aws_inventory/help/rds.md
267
+ - lib/aws_inventory/help/sg.md
268
+ - lib/aws_inventory/help/vpc.md
269
+ - lib/aws_inventory/iam.rb
270
+ - lib/aws_inventory/iam/group.rb
271
+ - lib/aws_inventory/iam/shared.rb
272
+ - lib/aws_inventory/iam/summary.rb
273
+ - lib/aws_inventory/iam/user.rb
274
+ - lib/aws_inventory/keypair.rb
275
+ - lib/aws_inventory/presenter.rb
276
+ - lib/aws_inventory/presenters/base.rb
277
+ - lib/aws_inventory/presenters/json.rb
278
+ - lib/aws_inventory/presenters/tab.rb
279
+ - lib/aws_inventory/presenters/table.rb
280
+ - lib/aws_inventory/rds.rb
281
+ - lib/aws_inventory/rds/port.rb
282
+ - lib/aws_inventory/rds/shared.rb
283
+ - lib/aws_inventory/rds/summary.rb
284
+ - lib/aws_inventory/route53.rb
285
+ - lib/aws_inventory/security_group.rb
286
+ - lib/aws_inventory/security_group/open.rb
287
+ - lib/aws_inventory/security_group/shared.rb
288
+ - lib/aws_inventory/security_group/summary.rb
289
+ - lib/aws_inventory/security_group/unused.rb
290
+ - lib/aws_inventory/shared.rb
291
+ - lib/aws_inventory/version.rb
292
+ - lib/aws_inventory/vpc.rb
293
+ - spec/lib/aws_inventory/base_spec.rb
294
+ - spec/lib/aws_inventory/security_group/open_spec.rb
293
295
  - spec/lib/cli_spec.rb
294
- - spec/lib/inventory/base_spec.rb
295
- - spec/lib/inventory/security_group/open_spec.rb
296
296
  - spec/spec_helper.rb
297
297
  homepage: https://github.com/tongueroo/aws-inventory
298
298
  licenses:
@@ -319,7 +319,7 @@ signing_key:
319
319
  specification_version: 4
320
320
  summary: Tool to inventory AWS account
321
321
  test_files:
322
+ - spec/lib/aws_inventory/base_spec.rb
323
+ - spec/lib/aws_inventory/security_group/open_spec.rb
322
324
  - spec/lib/cli_spec.rb
323
- - spec/lib/inventory/base_spec.rb
324
- - spec/lib/inventory/security_group/open_spec.rb
325
325
  - spec/spec_helper.rb
@@ -1,27 +0,0 @@
1
- $:.unshift(File.expand_path("../", __FILE__))
2
- require "inventory/version"
3
- require "text-table"
4
- require "active_support/all"
5
-
6
- module Inventory
7
- autoload :Base, "inventory/base"
8
- autoload :Help, "inventory/help"
9
- autoload :Command, "inventory/command"
10
- autoload :CLI, "inventory/cli"
11
- autoload :AwsServices, "inventory/aws_services"
12
- autoload :Shared, "inventory/shared"
13
- autoload :Presenter, "inventory/presenter"
14
- autoload :Cfn, "inventory/cfn"
15
- autoload :Ec2, "inventory/ec2"
16
- autoload :Vpc, "inventory/vpc"
17
- autoload :SecurityGroup, "inventory/security_group"
18
- autoload :Rds, "inventory/rds"
19
- autoload :Route53, "inventory/route53"
20
- autoload :Acm, "inventory/acm"
21
- autoload :Elb, "inventory/elb"
22
- autoload :Eb, "inventory/eb"
23
- autoload :Ecs, "inventory/ecs"
24
- autoload :Keypair, "inventory/keypair"
25
- autoload :Iam, "inventory/iam"
26
- autoload :Cloudwatch, "inventory/cloudwatch"
27
- end
@@ -1,10 +0,0 @@
1
- class Inventory::Ecs < Inventory::Base
2
- autoload :Service, "inventory/ecs/service"
3
- autoload :Cluster, "inventory/ecs/cluster"
4
-
5
- # Override report
6
- def report
7
- Service.new(@options).report
8
- Cluster.new(@options).report
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- Reports the IAM inventory.
2
-
3
- List of groups and users in the groups:
4
-
5
- $ inventory iam --report groups # this is the default
6
-
7
- $ inventory iam # same as above
8
-
9
- List of the users and their groups:
10
-
11
- $ inventory iam --report users
12
-
13
- Summary of number of groups and users
14
-
15
- $ inventory iam --report summary
@@ -1,5 +0,0 @@
1
- Reports the RDS inventory
2
-
3
- $ inventory rds --report summary
4
-
5
- $ inventory rds --report port
@@ -1,21 +0,0 @@
1
- class Inventory::Presenter
2
- autoload :Base, "inventory/presenters/base"
3
- autoload :Tab, "inventory/presenters/tab"
4
- autoload :Table, "inventory/presenters/table"
5
- autoload :Json, "inventory/presenters/json"
6
-
7
- def initialize(data)
8
- @data = data
9
- end
10
-
11
- def display
12
- presenter_class = "Inventory::Presenter::#{format.classify}".constantize
13
- presenter = presenter_class.new(@data)
14
- presenter.display
15
- end
16
-
17
- # Formats: tabs, markdown
18
- def format
19
- ENV['AWS_INVENTORY_FORMAT'] || "table"
20
- end
21
- end
@@ -1,5 +0,0 @@
1
- class Inventory::Presenter::Base
2
- def initialize(data)
3
- @data = data
4
- end
5
- end
@@ -1,11 +0,0 @@
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
@@ -1,7 +0,0 @@
1
- class Inventory::Presenter::Tab < Inventory::Presenter::Base
2
- def display
3
- @data.each do |row|
4
- puts row.join("\t")
5
- end
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- require 'text-table'
2
-
3
- class Inventory::Presenter::Table < Inventory::Presenter::Base
4
- def display
5
- table = Text::Table.new
6
- table.head = @data.shift
7
- table.rows = @data
8
- puts table
9
- end
10
- end
@@ -1,13 +0,0 @@
1
- class Inventory::SecurityGroup < Inventory::Base
2
- autoload :Shared, "inventory/security_group/shared"
3
- autoload :Summary, "inventory/security_group/summary"
4
- autoload :Open, "inventory/security_group/open"
5
- autoload :Unused, "inventory/security_group/unused"
6
-
7
- # Default is the open report because it seems like the most useful report
8
- def report
9
- Summary.new(@options).report if show(:summary)
10
- Open.new(@options).report if show(:open)
11
- Unused.new(@options.report).report if show(:unused)
12
- end
13
- end
@@ -1,3 +0,0 @@
1
- module Inventory
2
- VERSION = "0.3.2"
3
- end
@@ -1,7 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Inventory::Base do
4
- it "eager_load!" do
5
- Inventory::Base.eager_load!
6
- end
7
- end