Module: AwsPublicIps::Checks::Elb

Defined in:
lib/aws_public_ips/checks/elb.rb

Class Method Summary collapse

Class Method Details

.runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aws_public_ips/checks/elb.rb', line 9

def self.run
  client = Aws::ElasticLoadBalancing::Client.new

  # EC2-Classic load balancers are only returned by the 'elasticloadbalancing' API, and
  # EC2-VPC ALBs/NLBs are only returned by the 'elasticloadbalancingv2' API
  client.describe_load_balancers.flat_map do |response|
    response.load_balancer_descriptions.flat_map do |load_balancer|
      next [] unless load_balancer.scheme == 'internet-facing'
      {
        id: load_balancer.canonical_hosted_zone_name_id,
        hostname: load_balancer.dns_name,
        # EC2-Classic load balancers get IPv6 DNS records created but they are not returned by the API
        ip_addresses: Utils.resolve_hostnames([load_balancer.dns_name, "ipv6.#{load_balancer.dns_name}"])
      }
    end
  end
end