Skip to content

Commit 38e7862

Browse files
authored
Merge pull request kubernetes-sigs#3433 from jwenz723/master
Add AWS VPC endpoint canonical hosted zone IDs
2 parents f4acab1 + 31f0615 commit 38e7862

File tree

3 files changed

+48
-55
lines changed

3 files changed

+48
-55
lines changed

docs/tutorials/aws.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ Annotations which are specific to AWS.
557557

558558
`external-dns.alpha.kubernetes.io/alias` if set to `true` on an ingress, it will create an ALIAS record when the target is an ALIAS as well. To make the target an alias, the ingress needs to be configured correctly as described in [the docs](./nginx-ingress.md#with-a-separate-tcp-load-balancer). In particular, the argument `--publish-service=default/nginx-ingress-controller` has to be set on the `nginx-ingress-controller` container. If one uses the `nginx-ingress` Helm chart, this flag can be set with the `controller.publishService.enabled` configuration option.
559559

560+
### target-hosted-zone
561+
562+
`external-dns.alpha.kubernetes.io/aws-target-hosted-zone` can optionally be set to the ID of a Route53 hosted zone. This will force external-dns to use the specified hosted zone when creating an ALIAS target.
563+
560564
## Verify ExternalDNS works (Service example)
561565

562566
Create the following sample application to test that ExternalDNS works.
@@ -833,6 +837,14 @@ You can configure Route53 to associate DNS records with healthchecks for automat
833837

834838
Note: ExternalDNS does not support creating healthchecks, and assumes that `<health-check-id>` already exists.
835839

840+
## Canonical Hosted Zones
841+
842+
When creating ALIAS type records in Route53 it is required that external-dns be aware of the canonical hosted zone in which
843+
the specified hostname is created. External-dns is able to automatically identify the canonical hosted zone for many
844+
hostnames based upon known hostname suffixes which are defined in [aws.go](../../provider/aws/aws.go). If a hostname
845+
does not have a known suffix then the suffix can be added into `aws.go` or the [target-hosted-zone annotation](#target-hosted-zone)
846+
can be used to manually define the ID of the canonical hosted zone.
847+
836848
## Govcloud caveats
837849

838850
Due to the special nature with how Route53 runs in Govcloud, there are a few tweaks in the deployment settings.

provider/aws/aws.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,36 @@ var canonicalHostedZones = map[string]string{
127127
"awsglobalaccelerator.com": "Z2BJ6XQ5FK7U4H",
128128
// Cloudfront
129129
"cloudfront.net": "Z2FDTNDATAQYW2",
130+
// VPC Endpoint (PrivateLink)
131+
"eu-west-2.vpce.amazonaws.com": "Z7K1066E3PUKB",
132+
"us-east-2.vpce.amazonaws.com": "ZC8PG0KIFKBRI",
133+
"af-south-1.vpce.amazonaws.com": "Z09302161J80N9A7UTP7U",
134+
"ap-east-1.vpce.amazonaws.com": "Z2LIHJ7PKBEMWN",
135+
"ap-northeast-1.vpce.amazonaws.com": "Z2E726K9Y6RL4W",
136+
"ap-northeast-2.vpce.amazonaws.com": "Z27UANNT0PRK1T",
137+
"ap-northeast-3.vpce.amazonaws.com": "Z376B5OMM2JZL2",
138+
"ap-south-1.vpce.amazonaws.com": "Z2KVTB3ZLFM7JR",
139+
"ap-south-2.vpce.amazonaws.com": "Z0952991RWSF5AHIQDIY",
140+
"ap-southeast-1.vpce.amazonaws.com": "Z18LLCSTV4NVNL",
141+
"ap-southeast-2.vpce.amazonaws.com": "ZDK2GCRPAFKGO",
142+
"ap-southeast-3.vpce.amazonaws.com": "Z03881013RZ9BYYZO8N5W",
143+
"ap-southeast-4.vpce.amazonaws.com": "Z07508191CO1RNBX3X3AU",
144+
"ca-central-1.vpce.amazonaws.com": "ZRCXCF510Y6P9",
145+
"eu-central-1.vpce.amazonaws.com": "Z273ZU8SZ5RJPC",
146+
"eu-central-2.vpce.amazonaws.com": "Z045369019J4FUQ4S272E",
147+
"eu-north-1.vpce.amazonaws.com": "Z3OWWK6JFDEDGC",
148+
"eu-south-1.vpce.amazonaws.com": "Z2A5FDNRLY7KZG",
149+
"eu-south-2.vpce.amazonaws.com": "Z014396544HENR57XQCJ",
150+
"eu-west-1.vpce.amazonaws.com": "Z38GZ743OKFT7T",
151+
"eu-west-3.vpce.amazonaws.com": "Z1DWHTMFP0WECP",
152+
"me-central-1.vpce.amazonaws.com": "Z07122992YCEUCB9A9570",
153+
"me-south-1.vpce.amazonaws.com": "Z3B95P3VBGEQGY",
154+
"sa-east-1.vpce.amazonaws.com": "Z2LXUWEVLCVZIB",
155+
"us-east-1.vpce.amazonaws.com": "Z7HUB22UULQXV",
156+
"us-gov-east-1.vpce.amazonaws.com": "Z2MU5TEIGO9WXB",
157+
"us-gov-west-1.vpce.amazonaws.com": "Z12529ZODG2B6H",
158+
"us-west-1.vpce.amazonaws.com": "Z12I86A8N7VCZO",
159+
"us-west-2.vpce.amazonaws.com": "Z1YSA3EXCYUU9Z",
130160
}
131161

132162
// Route53API is the subset of the AWS Route53 API that we actually use. Add methods as required. Signatures must match exactly.

provider/aws/aws_test.go

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,62 +1183,13 @@ func TestAWSisAWSAlias(t *testing.T) {
11831183
}
11841184

11851185
func TestAWSCanonicalHostedZone(t *testing.T) {
1186-
for _, tc := range []struct {
1187-
hostname string
1188-
expected string
1189-
}{
1190-
// Application Load Balancers and Classic Load Balancers
1191-
{"foo.us-east-2.elb.amazonaws.com", "Z3AADJGX6KTTL2"},
1192-
{"foo.us-east-1.elb.amazonaws.com", "Z35SXDOTRQ7X7K"},
1193-
{"foo.us-west-1.elb.amazonaws.com", "Z368ELLRRE2KJ0"},
1194-
{"foo.us-west-2.elb.amazonaws.com", "Z1H1FL5HABSF5"},
1195-
{"foo.ca-central-1.elb.amazonaws.com", "ZQSVJUPU6J1EY"},
1196-
{"foo.ap-east-1.elb.amazonaws.com", "Z3DQVH9N71FHZ0"},
1197-
{"foo.ap-south-1.elb.amazonaws.com", "ZP97RAFLXTNZK"},
1198-
{"foo.ap-northeast-2.elb.amazonaws.com", "ZWKZPGTI48KDX"},
1199-
{"foo.ap-northeast-3.elb.amazonaws.com", "Z5LXEXXYW11ES"},
1200-
{"foo.ap-southeast-1.elb.amazonaws.com", "Z1LMS91P8CMLE5"},
1201-
{"foo.ap-southeast-2.elb.amazonaws.com", "Z1GM3OXH4ZPM65"},
1202-
{"foo.ap-southeast-3.elb.amazonaws.com", "Z08888821HLRG5A9ZRTER"},
1203-
{"foo.ap-northeast-1.elb.amazonaws.com", "Z14GRHDCWA56QT"},
1204-
{"foo.eu-central-1.elb.amazonaws.com", "Z215JYRZR1TBD5"},
1205-
{"foo.eu-west-1.elb.amazonaws.com", "Z32O12XQLNTSW2"},
1206-
{"foo.eu-west-2.elb.amazonaws.com", "ZHURV8PSTC4K8"},
1207-
{"foo.eu-west-3.elb.amazonaws.com", "Z3Q77PNBQS71R4"},
1208-
{"foo.eu-south-1.elb.amazonaws.com", "Z3ULH7SSC9OV64"},
1209-
{"foo.sa-east-1.elb.amazonaws.com", "Z2P70J7HTTTPLU"},
1210-
{"foo.cn-north-1.elb.amazonaws.com.cn", "Z1GDH35T77C1KE"},
1211-
{"foo.cn-northwest-1.elb.amazonaws.com.cn", "ZM7IZAIOVVDZF"},
1212-
{"foo.af-south-1.elb.amazonaws.com", "Z268VQBMOI5EKX"},
1213-
// Network Load Balancers
1214-
{"foo.elb.us-east-2.amazonaws.com", "ZLMOA37VPKANP"},
1215-
{"foo.elb.us-east-1.amazonaws.com", "Z26RNL4JYFTOTI"},
1216-
{"foo.elb.us-west-1.amazonaws.com", "Z24FKFUX50B4VW"},
1217-
{"foo.elb.us-west-2.amazonaws.com", "Z18D5FSROUN65G"},
1218-
{"foo.elb.ca-central-1.amazonaws.com", "Z2EPGBW3API2WT"},
1219-
{"foo.elb.ap-east-1.amazonaws.com", "Z12Y7K3UBGUAD1"},
1220-
{"foo.elb.ap-south-1.amazonaws.com", "ZVDDRBQ08TROA"},
1221-
{"foo.elb.ap-northeast-3.amazonaws.com", "Z1GWIQ4HH19I5X"},
1222-
{"foo.elb.ap-northeast-2.amazonaws.com", "ZIBE1TIR4HY56"},
1223-
{"foo.elb.ap-southeast-1.amazonaws.com", "ZKVM4W9LS7TM"},
1224-
{"foo.elb.ap-southeast-2.amazonaws.com", "ZCT6FZBF4DROD"},
1225-
{"foo.elb.ap-southeast-3.amazonaws.com", "Z01971771FYVNCOVWJU1G"},
1226-
{"foo.elb.ap-northeast-1.amazonaws.com", "Z31USIVHYNEOWT"},
1227-
{"foo.elb.eu-central-1.amazonaws.com", "Z3F0SRJ5LGBH90"},
1228-
{"foo.elb.eu-west-1.amazonaws.com", "Z2IFOLAFXWLO4F"},
1229-
{"foo.elb.eu-west-2.amazonaws.com", "ZD4D7Y8KGAS4G"},
1230-
{"foo.elb.eu-west-3.amazonaws.com", "Z1CMS0P5QUZ6D5"},
1231-
{"foo.elb.eu-south-1.amazonaws.com", "Z23146JA1KNAFP"},
1232-
{"foo.elb.sa-east-1.amazonaws.com", "ZTK26PT1VY4CU"},
1233-
{"foo.elb.cn-north-1.amazonaws.com.cn", "Z3QFB96KMJ7ED6"},
1234-
{"foo.elb.cn-northwest-1.amazonaws.com.cn", "ZQEIKTCZ8352D"},
1235-
{"foo.elb.af-south-1.amazonaws.com", "Z203XCE67M25HM"},
1236-
// No Load Balancer
1237-
{"foo.example.org", ""},
1238-
} {
1239-
zone := canonicalHostedZone(tc.hostname)
1240-
assert.Equal(t, tc.expected, zone)
1186+
for suffix, id := range canonicalHostedZones {
1187+
zone := canonicalHostedZone(fmt.Sprintf("foo.%s", suffix))
1188+
assert.Equal(t, id, zone)
12411189
}
1190+
1191+
zone := canonicalHostedZone("foo.example.org")
1192+
assert.Equal(t, "", zone, "no canonical zone should be returned for a non-aws hostname")
12421193
}
12431194

12441195
func TestAWSSuitableZones(t *testing.T) {

0 commit comments

Comments
 (0)