Module: MovableInk::AWS::Route53

Included in:
MovableInk::AWS
Defined in:
lib/movable_ink/aws/route53.rb

Instance Method Summary collapse

Instance Method Details

#delete_resource_record_sets(zone, instance_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/movable_ink/aws/route53.rb', line 17

def delete_resource_record_sets(zone, instance_name)
  change_batch = {
    "changes": [{
      "action": 'DELETE',
      "resource_record_set": get_resource_record_sets_by_instance_name(zone, instance_name)
    }]
  }

  run_with_backoff do
    route53.change_resource_record_sets({change_batch: change_batch, hosted_zone_id: zone})
  end
end

#get_resource_record_sets_by_instance_name(zone, instance_name) ⇒ Object



13
14
15
# File 'lib/movable_ink/aws/route53.rb', line 13

def get_resource_record_sets_by_instance_name(zone, instance_name)
  resource_record_sets(zone).select{|rrs| rrs.set_identifier == instance_name}.first.to_h
end

#list_all_r53_resource_record_sets(hosted_zone_id) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/movable_ink/aws/route53.rb', line 30

def list_all_r53_resource_record_sets(hosted_zone_id)
  run_with_backoff do
    route53.list_resource_record_sets({
      hosted_zone_id: hosted_zone_id
    }).flat_map(&:resource_record_sets)
  end
end

#resource_record_sets(hosted_zone_id) ⇒ Object



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

def resource_record_sets(hosted_zone_id)
  @resource_record_sets ||= {}
  @resource_record_sets[hosted_zone_id] ||= list_all_r53_resource_record_sets(hosted_zone_id)
end

#route53 ⇒ Object



4
5
6
# File 'lib/movable_ink/aws/route53.rb', line 4

def route53
  @route53_client ||= Aws::Route53::Client.new(region: 'us-east-1')
end