Skip to content

Commit

Permalink
support API Gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
ayemos committed Nov 28, 2018
1 parent 12fdbc3 commit b63e6c2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/roadworker/route53-ext.rb
Expand Up @@ -66,6 +66,26 @@ module Route53
'us-west-2' => 'Z38NKT9BP95V3O',
}

# https://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region
API_GATEWAY_HOSTED_ZONE_NAME_IDS = {
"us-east-2" => "ZOJJZC49E0EPZ",
"us-east-1" => "Z1UJRXOUMOOFQ8",
"us-west-1" => "Z2MUQ32089INYE",
"us-west-2" => "Z2OJLYMUO9EFXC",
"ap-south-1" => "Z3VO1THU9YC4UR",
"ap-northeast-3" => "Z2YQB5RD63NC85",
"ap-northeast-2" => "Z20JF4UZKIW1U8",
"ap-southeast-1" => "ZL327KTPIQFUL",
"ap-southeast-2" => "Z2RPCDW04V8134",
"ap-northeast-1" => "Z1YSHQZHG15GKL",
"ca-central-1" => "Z19DQILCV0OWEC",
"eu-central-1" => "Z1U9ULNL0V5AJ3",
"eu-west-1" => "ZLY8HYME6SFDD",
"eu-west-2" => "ZJ5UAJN8Y3Z2Q",
"eu-west-3" => "Z3KY65QIEKYHQQ",
"sa-east-1" => "ZCMLWB8V5SYIT"
}

class << self
def normalize_dns_name_options(src)
dst = {}
Expand Down Expand Up @@ -100,6 +120,8 @@ def dns_name_to_alias_target(name, options, hosted_zone_id, hosted_zone_name)
elsif name =~ /\.([^.]+)\.elasticbeanstalk\.com\z/i
region = $1.downcase
eb_dns_name_to_alias_target(name, region)
elsif name =~ /(\A|\.)\.execute-api\.([^.]+)\.amazonaws\.com\z/i
apigw_dns_name_to_alias_target(name, hosted_zone_id, options)
else
raise "Invalid DNS Name: #{name}"
end
Expand Down Expand Up @@ -143,6 +165,14 @@ def s3_dns_name_to_alias_target(name, region, hosted_zone_id)
}
end

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

def cf_dns_name_to_alias_target(name)
{
:hosted_zone_id => CF_HOSTED_ZONE_ID,
Expand Down

0 comments on commit b63e6c2

Please sign in to comment.