Module: MovableInk::AWS::Route53
- Included in:
- MovableInk::AWS
- Defined in:
- lib/movable_ink/aws/route53.rb
Instance Method Summary collapse
- #delete_resource_record_sets(zone, instance_name, client = nil) ⇒ Object
- #find_health_check_by_tag(key, value, client = nil) ⇒ Object
- #get_health_check_tags(health_check_id, client = nil) ⇒ Object
- #get_resource_record_sets_by_instance_name(zone, instance_name, client = nil) ⇒ Object
- #list_all_r53_resource_record_sets(hosted_zone_id, client = nil) ⇒ Object
- #list_health_checks(client = nil) ⇒ Object
- #resource_record_sets(hosted_zone_id, client = nil) ⇒ Object
- #route53(client = nil) ⇒ Object
Instance Method Details
#delete_resource_record_sets(zone, instance_name, client = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/movable_ink/aws/route53.rb', line 19 def delete_resource_record_sets(zone, instance_name, client = nil) resource_record_sets = get_resource_record_sets_by_instance_name(zone, instance_name, client) return if resource_record_sets.empty? change_batch = { "changes": resource_record_sets.map { |resource_record_set| { "action": 'DELETE', "resource_record_set": resource_record_set } } } run_with_backoff do route53(client).change_resource_record_sets({change_batch: change_batch, hosted_zone_id: zone}) end end |
#find_health_check_by_tag(key, value, client = nil) ⇒ Object
60 61 62 63 64 |
# File 'lib/movable_ink/aws/route53.rb', line 60 def find_health_check_by_tag(key, value, client = nil) list_health_checks(client).detect do |health_check| (health_check.id, client).detect { |tag| tag.key == key && tag.value.include?(value) } end end |
#get_health_check_tags(health_check_id, client = nil) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/movable_ink/aws/route53.rb', line 51 def (health_check_id, client = nil) run_with_backoff do route53(client).({ resource_type: 'healthcheck', resource_id: health_check_id }).resource_tag_set. end end |
#get_resource_record_sets_by_instance_name(zone, instance_name, client = nil) ⇒ Object
15 16 17 |
# File 'lib/movable_ink/aws/route53.rb', line 15 def get_resource_record_sets_by_instance_name(zone, instance_name, client = nil) resource_record_sets(zone, client).select{|rrs| rrs.set_identifier == instance_name}.map(&:to_h) end |
#list_all_r53_resource_record_sets(hosted_zone_id, client = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/movable_ink/aws/route53.rb', line 37 def list_all_r53_resource_record_sets(hosted_zone_id, client = nil) run_with_backoff do route53(client).list_resource_record_sets({ hosted_zone_id: hosted_zone_id }).flat_map(&:resource_record_sets) end end |
#list_health_checks(client = nil) ⇒ Object
45 46 47 48 49 |
# File 'lib/movable_ink/aws/route53.rb', line 45 def list_health_checks(client = nil) run_with_backoff do route53(client).list_health_checks().flat_map(&:health_checks) end end |
#resource_record_sets(hosted_zone_id, client = nil) ⇒ Object
10 11 12 13 |
# File 'lib/movable_ink/aws/route53.rb', line 10 def resource_record_sets(hosted_zone_id, client = nil) @resource_record_sets ||= {} @resource_record_sets[hosted_zone_id] ||= list_all_r53_resource_record_sets(hosted_zone_id, client) end |
#route53(client = nil) ⇒ Object
6 7 8 |
# File 'lib/movable_ink/aws/route53.rb', line 6 def route53(client = nil) @route53_client ||= (client) ? client : Aws::Route53::Client.new(region: 'us-east-1') end |