Class: Stax::Aws::Route53

Inherits:
Sdk
  • Object
show all
Defined in:
lib/stax/aws/route53.rb

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



7
8
9
# File 'lib/stax/aws/route53.rb', line 7

def client
  @_client ||= ::Aws::Route53::Client.new
end

.record(name, type = :A) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/stax/aws/route53.rb', line 36

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 = {}) ⇒ Object

record sets for named zone



32
33
34
# File 'lib/stax/aws/route53.rb', line 32

def record_sets(opt = {})
  client.list_resource_record_sets(opt)&.resource_record_sets
end

.zone_by_name(name) ⇒ Object

get single matching zone, or nil



25
26
27
28
29
# File 'lib/stax/aws/route53.rb', line 25

def zone_by_name(name)
  zones_by_name(name, 1).find do |zone|
    zone.name == name
  end
end

.zonesObject

list all zones



12
13
14
# File 'lib/stax/aws/route53.rb', line 12

def zones
  client.list_hosted_zones.hosted_zones
end

.zones_by_name(name, max_items = nil) ⇒ Object

list limited number of zones, starting at named zone



17
18
19
20
21
22
# File 'lib/stax/aws/route53.rb', line 17

def zones_by_name(name, max_items = nil)
  client.list_hosted_zones_by_name(
    dns_name: name,
    max_items: max_items,
  )&.hosted_zones
end