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

feat(route53): support zone roots as record names #2705

Merged
merged 1 commit into from
May 31, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-route53/lib/records/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IHostedZone } from '../hosted-zone-ref';
*
* @returns <ul>
* <li>If +providedName+ ends with a +.+, use it as-is</li>
* <li>If +providedName+ ends with +zoneName+, append a trailing +.+</li>
* <li>If +providedName+ ends with or equals +zoneName+, append a trailing +.+</li>
* <li>Otherwise, append +.+, +zoneName+ and a trailing +.+</li>
* </ul>
*/
Expand All @@ -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}.`;
}

Expand Down
36 changes: 36 additions & 0 deletions packages/@aws-cdk/aws-route53/test/test.alias-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};