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
|
# File 'lib/aws_public_ips/checks/redshift.rb', line 9
def self.run
client = ::Aws::Redshift::Client.new
return [] unless ::AwsPublicIps::Utils.has_service?(client)
client.describe_clusters.flat_map do |response|
response.clusters.flat_map do |cluster|
next [] unless cluster.publicly_accessible
if cluster.endpoint.nil?
raise StandardError, "Redshift cluster '#{cluster.cluster_identifier}' has a nil endpoint. This likely" \
' means the cluster is being brought up right now.'
end
{
id: cluster.cluster_identifier,
hostname: cluster.endpoint.address,
ip_addresses: cluster.cluster_nodes.map(&:public_ip_address) +
::AwsPublicIps::Utils.resolve_hostname(cluster.endpoint.address)
}
end
end
end
|