Class: Vaws::Aws::AlbDescriber

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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
# File 'lib/vaws/aws/alb_describer.rb', line 14

def set_basic_info
  rows = []
  albs = @alb_client.describe_load_balancers

  # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ElasticLoadBalancingV2/Client.html#describe_load_balancers-instance_method
  albs.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]
  end
  @term_table = Terminal::Table.new :headings => ['Name', 'Type', 'Scheme', 'Vpc', 'Short_Arn', 'Dns'], :rows => rows.sort
end