Skip to content

Commit

Permalink
Merge pull request #21 from yteraoka/cross-account-elb-alias
Browse files Browse the repository at this point in the history
support cross account ELB Alias
  • Loading branch information
Genki Sugawara committed Sep 10, 2015
2 parents b32be44 + 0e7bfef commit fd1aa1e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/roadworker/route53-ext.rb
Expand Up @@ -25,6 +25,7 @@ def normalize_dns_name_options(src)
dst = {}

{
:hosted_zone_id => false,
:evaluate_target_health => false,
}.each do |key, defalut_value|
dst[key] = src[key] || false
Expand All @@ -40,7 +41,7 @@ def dns_name_to_alias_target(name, options, hosted_zone_id, hosted_zone_name)

if name =~ /([^.]+)\.elb\.amazonaws.com\Z/i
region = $1.downcase
alias_target = elb_dns_name_to_alias_target(name, region)
alias_target = elb_dns_name_to_alias_target(name, region, options)

# XXX:
alias_target.merge(options)
Expand All @@ -58,7 +59,7 @@ def dns_name_to_alias_target(name, options, hosted_zone_id, hosted_zone_name)

private

def elb_dns_name_to_alias_target(name, region)
def elb_dns_name_to_alias_target(name, region, options)
elb = Aws::ElasticLoadBalancing::Client.new(:region => region)

load_balancer = nil
Expand All @@ -72,7 +73,15 @@ def elb_dns_name_to_alias_target(name, region)
end

unless load_balancer
raise "Cannot find ELB: #{name}"
if options[:hosted_zone_id]
return {
:hosted_zone_id => options[:hosted_zone_id],
:dns_name => name,
:evaluate_target_health => false, # XXX:
}
else
raise "Cannot find ELB: #{name}"
end
end

{
Expand Down

0 comments on commit fd1aa1e

Please sign in to comment.