Class: Vaws::Aws::AlbDescriber

Inherits:
Describer show all
Defined in:
lib/vaws/aws/alb_describer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Describer

#single_option_validation

Constructor Details

#initializeAlbDescriber

Returns a new instance of AlbDescriber.



9
10
11
12
# File 'lib/vaws/aws/alb_describer.rb', line 9

def initialize
  @alb_client = ::Aws::ElasticLoadBalancingV2::Client.new
  @term_table = ''
end

Instance Attribute Details

#term_tableObject (readonly)

Returns the value of attribute term_table.



7
8
9
# File 'lib/vaws/aws/alb_describer.rb', line 7

def term_table
  @term_table
end

Instance Method Details

#set_basic_infoObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vaws/aws/alb_describer.rb', line 14

def set_basic_info
  rows        = []
  next_marker = nil

  begin
    param_args          = {
      page_size: 400
    }
    param_args[:marker] = next_marker if next_marker
    resp                = @alb_client.describe_load_balancers(param_args)

    # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ElasticLoadBalancingV2/Client.html#describe_load_balancers-instance_method
    resp.load_balancers.each do |alb|
      arn    = alb.load_balancer_arn.sub!(/arn:aws:elasticloadbalancing:ap-northeast-1:163714994724:loadbalancer\/...\//, '')
      dns    = alb.dns_name
      name   = alb.load_balancer_name
      scheme = alb.scheme
      vpc    = alb.vpc_id
      type   = alb.type
      rows << [name, type, scheme, vpc, arn, dns]
      next_marker = resp.next_marker
    end
  end while next_marker
  @term_table = Terminal::Table.new :headings => ['Name', 'Type', 'Scheme', 'Vpc', 'Short_Arn', 'Dns'], :rows => rows.sort
end