Module: Furikake::Resources::Alb
- Defined in:
- lib/furikake/resources/alb.rb
Class Method Summary collapse
Class Method Details
.get_resources ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/furikake/resources/alb.rb', line 40 def get_resources alb = Aws::ElasticLoadBalancingV2::Client.new albs = [] target_groups = [] alb.describe_load_balancers.load_balancers.each do |lb| alb_info = [] t = alb.describe_target_groups({ load_balancer_arn: lb.load_balancer_arn }).target_groups.map(&:to_h) alb_info << lb.load_balancer_name alb_info << lb.dns_name alb_info << lb.type alb_info << (t.map {|a| a[:target_group_name]}).join(", ") albs << alb_info target_group = [] target_group << (t.map {|a| a[:target_group_name]}).join(", ") target_group << (t.map {|a| a[:protocol]}).join(", ") target_group << (t.map {|a| a[:port]}).join(", ") target_group << (t.map {|a| a[:health_check_path].nil? ? " " : a[:health_check_path]}).join(", ") target_group << (t.map {|a| a[:health_check_port]}).join(", ") target_group << (t.map {|a| a[:health_check_protocol]}).join(", ") target_groups << target_group end return albs, target_groups end |
.report ⇒ Object
4 5 6 7 8 9 10 11 12 13 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/furikake/resources/alb.rb', line 4 def report albs, target_groups = get_resources headers = ['LB Name', 'DNS Name', 'Type', 'Target Group'] if albs.empty? albs_info = 'N/A' else albs_info = MarkdownTables.make_table(headers, albs, is_rows: true, align: 'l') end headers = ['Target Group Name', 'Protocal', 'Port', 'Health Check Path', 'Health Chack Port', 'Health Check Protocol'] if target_groups.empty? target_group_info = 'N/A' else target_group_info = MarkdownTables.make_table(headers, target_groups, is_rows: true, align: 'l') end documents = <<"EOS" ### ELB (ALB / NLB) #### ALB / NLB #{albs_info} #### Target Groups #{target_group_info} EOS documents end |