Module: Awspec::Helper::Finder::Route53

Included in:
Awspec::Helper::Finder
Defined in:
lib/awspec/helper/finder/route53.rb

Instance Method Summary collapse

Instance Method Details

#find_hosted_zone(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/awspec/helper/finder/route53.rb', line 6

def find_hosted_zone(id)
  res = route53_client.list_hosted_zones
  selected = []
  loop do
    res.hosted_zones.each do |hosted_zone|
      if hosted_zone[:name] == id || hosted_zone[:id] == "/hostedzone/#{id}" || hosted_zone[:id] == id
        selected.push(hosted_zone)
      end
    end

    break unless res.is_truncated

    res = route53_client.list_hosted_zones({
                                             marker: res.next_marker
                                           })
  end
  selected.single_resource(id)
end

#select_record_sets_by_hosted_zone_id(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/awspec/helper/finder/route53.rb', line 25

def select_record_sets_by_hosted_zone_id(id)
  selected = []
  res = route53_client.list_resource_record_sets({
                                                   hosted_zone_id: id
                                                 })
  loop do
    selected += res.resource_record_sets
    break unless res.is_truncated

    res = route53_client.list_resource_record_sets({
                                                     hosted_zone_id: id,
                                                     start_record_name: res.next_record_name,
                                                     start_record_type: res.next_record_type
                                                   })
  end
  selected
end