diff --git a/packages/@aws-cdk/aws-route53/lib/records/_util.ts b/packages/@aws-cdk/aws-route53/lib/records/_util.ts
index b51a2f89620a8..ba503721f258c 100644
--- a/packages/@aws-cdk/aws-route53/lib/records/_util.ts
+++ b/packages/@aws-cdk/aws-route53/lib/records/_util.ts
@@ -11,7 +11,7 @@ import { IHostedZone } from '../hosted-zone-ref';
*
* @returns
* - If +providedName+ ends with a +.+, use it as-is
- * - If +providedName+ ends with +zoneName+, append a trailing +.+
+ * - If +providedName+ ends with or equals +zoneName+, append a trailing +.+
* - Otherwise, append +.+, +zoneName+ and a trailing +.+
*
*/
@@ -21,7 +21,7 @@ export function determineFullyQualifiedDomainName(providedName: string, hostedZo
}
const suffix = `.${hostedZone.zoneName}`;
- if (providedName.endsWith(suffix)) {
+ if (providedName.endsWith(suffix) || providedName === hostedZone.zoneName) {
return `${providedName}.`;
}
diff --git a/packages/@aws-cdk/aws-route53/test/test.alias-record.ts b/packages/@aws-cdk/aws-route53/test/test.alias-record.ts
index a44005631df18..412f0f271d17d 100644
--- a/packages/@aws-cdk/aws-route53/test/test.alias-record.ts
+++ b/packages/@aws-cdk/aws-route53/test/test.alias-record.ts
@@ -38,6 +38,42 @@ export = {
}
}));
+ test.done();
+ },
+ 'test alias record on zone root'(test: Test) {
+ // GIVEN
+ const stack = new Stack();
+ const zone = new PublicHostedZone(stack, 'HostedZone', { zoneName: 'test.public' });
+
+ const target: IAliasRecordTarget = {
+ bind: () => {
+ return {
+ hostedZoneId: 'Z2P70J7EXAMPLE',
+ dnsName: 'foo.example.com'
+ };
+ }
+ };
+
+ // WHEN
+ new AliasRecord(zone, 'Alias', {
+ zone,
+ recordName: 'test.public',
+ target
+ });
+
+ // THEN - stack contains a record set
+ expect(stack).to(haveResource('AWS::Route53::RecordSet', {
+ Name: 'test.public.',
+ HostedZoneId: {
+ Ref: 'HostedZoneDB99F866'
+ },
+ Type: 'A',
+ AliasTarget: {
+ HostedZoneId: 'Z2P70J7EXAMPLE',
+ DNSName: 'foo.example.com',
+ }
+ }));
+
test.done();
}
};