Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support cross account ELB Alias #21

Merged
merged 1 commit into from
Sep 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/roadworker/route53-ext.rb
Original file line number Diff line number Diff line change
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