class Vaws::Aws::VpcDescriber

Attributes

term_table[R]

Public Class Methods

new() click to toggle source
# File lib/vaws/aws/vpc_describer.rb, line 9
def initialize
  @vpc_client = ::Aws::EC2::Client.new
  @term_table = ''
end

Public Instance Methods

set_basic_info() click to toggle source
# File lib/vaws/aws/vpc_describer.rb, line 14
def set_basic_info
  rows       = []
  next_token = nil

  begin
    param_args              = {
      max_results: 100
    }
    param_args[:next_token] = next_token if next_token
    resp                    = @vpc_client.describe_vpcs(param_args)
    resp.vpcs.each do |vpc|
      cidr   = vpc.cidr_block
      vpc_id = vpc.vpc_id
      tags   = ''
      vpc.tags.each_with_index do |tag, index|
        tags << "#{tag.value}, "
        tags = tags.gsub(/, $/, '') if index == vpc.tags.size - 1
      end
      rows << [vpc_id, cidr, tags]
    end
    next_token = resp.next_token
  end while next_token
  @term_table = Terminal::Table.new :headings => ['VpcId', 'Cidr', 'Tags'], :rows => rows.sort
end