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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/movable_ink/aws/route53.rb', line 17 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
56 57 58 59 60 |
# File 'lib/movable_ink/aws/route53.rb', line 56 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
47 48 49 50 51 52 53 54 |
# File 'lib/movable_ink/aws/route53.rb', line 47 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
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
33 34 35 36 37 38 39 |
# File 'lib/movable_ink/aws/route53.rb', line 33 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
41 42 43 44 45 |
# File 'lib/movable_ink/aws/route53.rb', line 41 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
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 |