module AwsPublicIps::Checks::Apigateway

Public Class Methods

run() click to toggle source
# File lib/aws_public_ips/checks/apigateway.rb, line 9
def self.run
  client = ::Aws::APIGateway::Client.new
  return [] unless ::AwsPublicIps::Utils.has_service?(client)

  # TODO(arkadiy) https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-private-integration.html

  # APIGateway doesn't return the full domain in the response, we have to build
  # it using the api id and region
  client.get_rest_apis.flat_map do |response|
    response.items.map do |api|
      hostname = "#{api.id}.execute-api.#{client.config.region}.amazonaws.com"
      {
        id: api.id,
        hostname: hostname,
        ip_addresses: ::AwsPublicIps::Utils.resolve_hostname(hostname)
      }
    end
  end
end