module Aws::Route53
Constants
- API_GATEWAY_HOSTED_ZONE_NAME_IDS
-
docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region
- CANONICAL_HOSTED_ZONE_NAME_IDS
- CF_HOSTED_ZONE_ID
-
docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
- DUALSTACK_CANONICAL_HOSTED_ZONE_NAME_IDS
- ELASTIC_BEANSTALK_HOSTED_ZONE_NAME_IDS
-
docs.aws.amazon.com/general/latest/gr/rande.html#elasticbeanstalk_region
- NLB_CANONICAL_HOSTED_ZONE_NAME_IDS
- S3_WEBSITE_ENDPOINTS
Public Class Methods
Source
# File lib/roadworker/route53-ext.rb, line 129 def dns_name_to_alias_target(name, options, hosted_zone_id, hosted_zone_name) hosted_zone_name = hosted_zone_name.sub(/\.\z/, '') name = name.sub(/\.\z/, '') options ||= {} if name =~ /([^.]+)\.elb\.amazonaws.com\z/i # CLB or ALB region = $1.downcase alias_target = elb_dns_name_to_alias_target(name, region, options) # XXX: alias_target.merge(options) elsif name =~ /\.elb\.([^.]+)\.amazonaws\.com\z/i # NLB region = $1.downcase alias_target = nlb_dns_name_to_alias_target(name, region, options) elsif (s3_hosted_zone_id = S3_WEBSITE_ENDPOINTS[name.downcase]) and name =~ /\As3-website-([^.]+)\.amazonaws\.com\z/i region = $1.downcase s3_dns_name_to_alias_target(name, region, s3_hosted_zone_id) elsif name =~ /\.cloudfront\.net\z/i cf_dns_name_to_alias_target(name) elsif name =~ /(\A|\.)#{Regexp.escape(hosted_zone_name)}\z/i this_hz_dns_name_to_alias_target(name, hosted_zone_id, options) elsif name =~ /\.([^.]+)\.elasticbeanstalk\.com\z/i region = $1.downcase eb_dns_name_to_alias_target(name, region) elsif name =~ /\.execute-api\.([^.]+)\.amazonaws\.com\z/i region = $1.downcase apigw_dns_name_to_alias_target(name, region, hosted_zone_id) elsif name =~ /\.([^.]+)\.vpce\.amazonaws\.com\z/i region = $1.downcase vpce_dns_name_to_alias_target(name, region, hosted_zone_id) elsif name =~ /\.awsglobalaccelerator\.com\z/i globalaccelerator_dns_name_to_alias_target(name) else raise "Invalid DNS Name: #{name}" end end
Source
# File lib/roadworker/route53-ext.rb, line 117 def normalize_dns_name_options(src) dst = {} { :evaluate_target_health => false, }.each do |key, defalut_value| dst[key] = src[key] || false end return dst end
Source
# File lib/roadworker/route53-ext.rb, line 168 def sort_rrset_values(attribute, values) sort_lambda = case attribute when :resource_records # After aws-sdk-core v3.44.1, Aws::Route53::Types::ResourceRecord#to_s returns filtered string # like "{:value=>\"[FILTERED]\"}" (cf. https://github.com/aws/aws-sdk-ruby/pull/1941). # To keep backward compatibility, sort by the value of resource record explicitly. lambda { |i| i[:value] } else lambda { |i| i.to_s } end values.sort_by(&sort_lambda) end
Private Class Methods
Source
# File lib/roadworker/route53-ext.rb, line 234 def apigw_dns_name_to_alias_target(name, region, hosted_zone_id) { :hosted_zone_id => API_GATEWAY_HOSTED_ZONE_NAME_IDS[region], :dns_name => name, :evaluate_target_health => false, # XXX: } end
Source
# File lib/roadworker/route53-ext.rb, line 242 def cf_dns_name_to_alias_target(name) { :hosted_zone_id => CF_HOSTED_ZONE_ID, :dns_name => name, :evaluate_target_health => false, # XXX: } end
Source
# File lib/roadworker/route53-ext.rb, line 258 def eb_dns_name_to_alias_target(name, region) { :hosted_zone_id => ELASTIC_BEANSTALK_HOSTED_ZONE_NAME_IDS[region], :dns_name => name, :evaluate_target_health => false, # XXX: } end
Source
# File lib/roadworker/route53-ext.rb, line 185 def elb_dns_name_to_alias_target(name, region, options) if options[:hosted_zone_id] { :hosted_zone_id => options[:hosted_zone_id], :dns_name => name, :evaluate_target_health => false, # XXX: } else hosted_zone_id = nil if name =~ /\Adualstack\./i hosted_zone_id = DUALSTACK_CANONICAL_HOSTED_ZONE_NAME_IDS[region] else hosted_zone_id = CANONICAL_HOSTED_ZONE_NAME_IDS[region] end unless hosted_zone_id raise "Cannot find CanonicalHostedZoneNameID for `#{name}`. Please pass :hosted_zone_id" end { :hosted_zone_id => hosted_zone_id, :dns_name => name, :evaluate_target_health => false, # XXX: } end end
Source
# File lib/roadworker/route53-ext.rb, line 274 def globalaccelerator_dns_name_to_alias_target(name) # https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html { :hosted_zone_id => 'Z2BJ6XQ5FK7U4H', :dns_name => name, :evaluate_target_health => false, # XXX: } end
Source
# File lib/roadworker/route53-ext.rb, line 213 def nlb_dns_name_to_alias_target(name, region, options) hosted_zone_id = options[:hosted_zone_id] || NLB_CANONICAL_HOSTED_ZONE_NAME_IDS[region] unless hosted_zone_id raise "Cannot find hosted zone id for `#{name}` (region: #{region}). Please pass :hosted_zone_id option" end { hosted_zone_id: hosted_zone_id, dns_name: name, evaluate_target_health: false, # XXX: } end
Source
# File lib/roadworker/route53-ext.rb, line 226 def s3_dns_name_to_alias_target(name, region, hosted_zone_id) { :hosted_zone_id => hosted_zone_id, :dns_name => name, :evaluate_target_health => false, # XXX: } end
Source
# File lib/roadworker/route53-ext.rb, line 250 def this_hz_dns_name_to_alias_target(name, hosted_zone_id, options) { :hosted_zone_id => hosted_zone_id, :dns_name => name, :evaluate_target_health => options[:evaluate_target_health] || false } end
Source
# File lib/roadworker/route53-ext.rb, line 266 def vpce_dns_name_to_alias_target(name, region, hosted_zone_id) { :hosted_zone_id => hosted_zone_id, :dns_name => name, :evaluate_target_health => false, # XXX: } end