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
|
# File 'lib/aws_public_ips/checks/rds.rb', line 9
def self.run
client = ::Aws::RDS::Client.new
return [] unless ::AwsPublicIps::Utils.has_service?(client)
client.describe_db_instances.flat_map do |response|
response.db_instances.flat_map do |instance|
next [] unless instance.publicly_accessible
if instance.endpoint.nil?
raise StandardError, "RDS DB '#{instance.dbi_resource_id}' has a nil endpoint. This likely" \
' means the DB is being brought up right now.'
end
{
id: instance.dbi_resource_id,
hostname: instance.endpoint.address,
ip_addresses: ::AwsPublicIps::Utils.resolve_hostname(instance.endpoint.address)
}
end
end
end
|