Module: AwsPublicIps::Checks::Apigateway

Defined in:
lib/aws_public_ips/checks/apigateway.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
26
27
# 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