Module: AwsPublicIps::Checks::Redshift

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

Class Method Summary collapse

Class Method Details

.runObject



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

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

  # TODO(arkadiy) update copy from RDS
  # Redshift clusters can only be launched into VPCs. They can be marked as `publicly_accessible`,
  # in which case the VPC must have an Internet Gateway attached, and the DNS endpoint will
  # resolve to a public ip address
  client.describe_clusters.flat_map do |response|
    response.clusters.flat_map do |cluster|
      next [] unless cluster.publicly_accessible
      {
        id: cluster.cluster_identifier,
        hostname: cluster.endpoint.address,
        ip_addresses: cluster.cluster_nodes.map(&:public_ip_address)
      }
    end
  end
end