Class: Stax::Aws::Route53

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

Constant Summary

Constants inherited from Sdk

Sdk::RETRY_LIMIT

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



9
10
11
# File 'lib/stax/aws/route53.rb', line 9

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

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



38
39
40
41
42
43
44
45
46
47
# 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 = {}) ⇒ Object

record sets for named zone



34
35
36
# 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) ⇒ Object

get single matching zone, or nil



27
28
29
30
31
# 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

.zonesObject

list all zones



14
15
16
# File 'lib/stax/aws/route53.rb', line 14

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



19
20
21
22
23
24
# 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