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) ⇒ Object
- #find_health_check_by_tag(key, value) ⇒ Object
- #get_health_check_tags(health_check_id) ⇒ Object
- #get_resource_record_sets_by_instance_name(zone, instance_name) ⇒ Object
- #list_all_r53_resource_record_sets(hosted_zone_id) ⇒ Object
- #list_health_checks ⇒ Object
- #resource_record_sets(hosted_zone_id) ⇒ Object
- #route53 ⇒ Object
Instance Method Details
#delete_resource_record_sets(zone, instance_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/movable_ink/aws/route53.rb', line 19 def delete_resource_record_sets(zone, instance_name) resource_record_set = get_resource_record_sets_by_instance_name(zone, instance_name) return if resource_record_set.empty? change_batch = { "changes": [{ "action": 'DELETE', "resource_record_set": resource_record_set }] } run_with_backoff do route53.change_resource_record_sets({change_batch: change_batch, hosted_zone_id: zone}) end end |
#find_health_check_by_tag(key, value) ⇒ Object
58 59 60 61 62 |
# File 'lib/movable_ink/aws/route53.rb', line 58 def find_health_check_by_tag(key, value) list_health_checks.detect do |health_check| (health_check.id).detect { |tag| tag.key == key && tag.value.include?(value) } end end |
#get_health_check_tags(health_check_id) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/movable_ink/aws/route53.rb', line 49 def (health_check_id) run_with_backoff do route53.({ resource_type: 'healthcheck', resource_id: health_check_id }).resource_tag_set. end end |
#get_resource_record_sets_by_instance_name(zone, instance_name) ⇒ Object
15 16 17 |
# File 'lib/movable_ink/aws/route53.rb', line 15 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
35 36 37 38 39 40 41 |
# File 'lib/movable_ink/aws/route53.rb', line 35 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 |
#list_health_checks ⇒ Object
43 44 45 46 47 |
# File 'lib/movable_ink/aws/route53.rb', line 43 def list_health_checks run_with_backoff do route53.list_health_checks().flat_map(&:health_checks) end end |
#resource_record_sets(hosted_zone_id) ⇒ Object
10 11 12 13 |
# File 'lib/movable_ink/aws/route53.rb', line 10 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
6 7 8 |
# File 'lib/movable_ink/aws/route53.rb', line 6 def route53 @route53_client ||= Aws::Route53::Client.new(region: 'us-east-1') end |