Skip to content

Commit

Permalink
Merge pull request #45 from winebarrel/master
Browse files Browse the repository at this point in the history
merge from master
  • Loading branch information
Genki Sugawara committed Feb 6, 2017
2 parents 086736a + 45318a3 commit 32363ee
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/roadworker/route53-ext.rb
Expand Up @@ -50,6 +50,22 @@ module Route53
# http://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
CF_HOSTED_ZONE_ID = 'Z2FDTNDATAQYW2'

# http://docs.aws.amazon.com/general/latest/gr/rande.html#elasticbeanstalk_region
ELASTIC_BEANSTALK_HOSTED_ZONE_NAME_IDS = {
'ap-northeast-1' => 'Z1R25G3KIG2GBW',
'ap-northeast-2' => 'Z3JE5OI70TWKCP',
'ap-south-1' => 'Z18NTBI3Y7N9TZ',
'ap-southeast-1' => 'Z16FZ9L249IFLT',
'ap-southeast-2' => 'Z2PCDNR3VC2G1N',
'eu-central-1' => 'Z1FRNW7UH4DEZJ',
'eu-west-1' => 'Z2NYPWQ7DFZAZH',
'sa-east-1' => 'Z10X7K2B4QSOFV',
'us-east-1' => 'Z117KPS5GTRQ2G',
'us-east-2' => 'Z14LCN19Q5QHIC',
'us-west-1' => 'Z1LQECGX5PH1X',
'us-west-2' => 'Z38NKT9BP95V3O',
}

class << self
def normalize_dns_name_options(src)
dst = {}
Expand Down Expand Up @@ -81,6 +97,9 @@ def dns_name_to_alias_target(name, options, hosted_zone_id, hosted_zone_name)
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)
elsif name =~ /\.([^.]+)\.elasticbeanstalk\.com\z/i
region = $1.downcase
eb_dns_name_to_alias_target(name, region)
else
raise "Invalid DNS Name: #{name}"
end
Expand Down Expand Up @@ -139,6 +158,14 @@ def this_hz_dns_name_to_alias_target(name, hosted_zone_id)
:evaluate_target_health => false, # XXX:
}
end

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
end # of class method

end # Route53
Expand Down

0 comments on commit 32363ee

Please sign in to comment.