From e313179b08d4ded6a1d05e30b5d33f9aaf67dbd9 Mon Sep 17 00:00:00 2001 From: Matthew O'Riordan Date: Tue, 21 Jun 2016 15:28:57 +0100 Subject: [PATCH] AWS DNS - support newer DNS hosted zone IDs for dualstack ELBs --- .../dns/change_resource_record_sets.rb | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/fog/aws/requests/dns/change_resource_record_sets.rb b/lib/fog/aws/requests/dns/change_resource_record_sets.rb index 11d49c371..bb82dd7ba 100644 --- a/lib/fog/aws/requests/dns/change_resource_record_sets.rb +++ b/lib/fog/aws/requests/dns/change_resource_record_sets.rb @@ -3,7 +3,13 @@ module Fog class AWS def self.hosted_zone_for_alias_target(dns_name) - Hash[elb_hosted_zone_mapping.select { |k, _| + hosted_zones = if dns_name.match(/^dualstack\./) + elb_dualstack_hosted_zone_mapping + else + elb_hosted_zone_mapping + end + + Hash[hosted_zones.select { |k, _| dns_name =~ /\A.+\.#{k}\.elb\.amazonaws\.com\.?\z/ }].values.last end @@ -22,6 +28,21 @@ module Fog } end + # See https://forums.aws.amazon.com/message.jspa?messageID=612414 + def self.elb_dualstack_hosted_zone_mapping + @elb_dualstack_hosted_zone_mapping ||= { + "ap-northeast-1" => "Z14GRHDCWA56QT", + "ap-southeast-1" => "Z1LMS91P8CMLE5", + "ap-southeast-2" => "Z1GM3OXH4ZPM65", + "eu-central-1" => "Z215JYRZR1TBD5", + "eu-west-1" => "Z32O12XQLNTSW2", + "sa-east-1" => "Z2P70J7HTTTPLU", + "us-east-1" => "Z35SXDOTRQ7X7K", + "us-west-1" => "Z368ELLRRE2KJ0", + "us-west-2" => "Z1H1FL5HABSF5", + } + end + # Returns the xml request for a given changeset def self.change_resource_record_sets_data(zone_id, change_batch, version, options = {}) # AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use