class Stax::Aws::Route53

Public Class Methods

client() click to toggle source
# File lib/stax/aws/route53.rb, line 9
def client
  @_client ||= ::Aws::Route53::Client.new
end
record(name, type = :A) click to toggle source
# File lib/stax/aws/route53.rb, line 38
def record(name, type = :A)
  zone = name.split('.').last(2).join('.') + '.'
  Aws::Route53.record_sets(
    hosted_zone_id: zone_by_name(zone).id,
    start_record_name: name,
    start_record_type: type,
  ).select do |record|
    (record.name == name) && (record.type == type.to_s)
  end
end
record_sets(opt = {}) click to toggle source

record sets for named zone

# File lib/stax/aws/route53.rb, line 34
def record_sets(opt = {})
  client.list_resource_record_sets(opt)&.resource_record_sets
end
zone_by_name(name) click to toggle source

get single matching zone, or nil

# File lib/stax/aws/route53.rb, line 27
def zone_by_name(name)
  zones_by_name(name, 1).find do |zone|
    zone.name == name
  end
end
zones() click to toggle source

list all zones

# File lib/stax/aws/route53.rb, line 14
def zones
  client.list_hosted_zones.hosted_zones
end
zones_by_name(name, max_items = nil) click to toggle source

list limited number of zones, starting at named zone

# File lib/stax/aws/route53.rb, line 19
def zones_by_name(name, max_items = nil)
  client.list_hosted_zones_by_name(
    dns_name: name,
    max_items: max_items,
  )&.hosted_zones
end