diff --git a/packages/@aws-cdk/aws-route53/README.md b/packages/@aws-cdk/aws-route53/README.md index 1c4affa83e3a0..d4376f335d848 100644 --- a/packages/@aws-cdk/aws-route53/README.md +++ b/packages/@aws-cdk/aws-route53/README.md @@ -76,6 +76,21 @@ new route53.NsRecord(this, 'NSRecord', { }); ``` +To add a DS record to your zone: + +```ts +import * as route53 from '@aws-cdk/aws-route53'; + +new route53.DsRecord(this, 'DSRecord', { + zone: myZone, + recordName: 'foo', + values: [ + '12345 3 1 123456789abcdef67890123456789abcdef67890', + ], + ttl: Duration.minutes(90), // Optional - default is 30 minutes +}); +``` + To add an A record to your zone: ```ts diff --git a/packages/@aws-cdk/aws-route53/lib/record-set.ts b/packages/@aws-cdk/aws-route53/lib/record-set.ts index 57f93931c2097..97be9070e2483 100644 --- a/packages/@aws-cdk/aws-route53/lib/record-set.ts +++ b/packages/@aws-cdk/aws-route53/lib/record-set.ts @@ -59,6 +59,13 @@ export enum RecordType { */ CNAME = 'CNAME', + /** + * A delegation signer (DS) record refers a zone key for a delegated subdomain zone. + * + * @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html#DSFormat + */ + DS = 'DS', + /** * An MX record specifies the names of your mail servers and, if you have two or more mail servers, * the priority order. @@ -566,6 +573,31 @@ export class NsRecord extends RecordSet { } } +/** + * Construction properties for a DSRecord. + */ +export interface DsRecordProps extends RecordSetOptions { + /** + * The DS values. + */ + readonly values: string[]; +} + +/** + * A DNS DS record + * + * @resource AWS::Route53::RecordSet + */ +export class DsRecord extends RecordSet { + constructor(scope: Construct, id: string, props: DsRecordProps) { + super(scope, id, { + ...props, + recordType: RecordType.DS, + target: RecordTarget.fromValues(...props.values), + }); + } +} + /** * Construction properties for a ZoneDelegationRecord */ diff --git a/packages/@aws-cdk/aws-route53/package.json b/packages/@aws-cdk/aws-route53/package.json index b079836648fe9..0d2b11232db8f 100644 --- a/packages/@aws-cdk/aws-route53/package.json +++ b/packages/@aws-cdk/aws-route53/package.json @@ -112,6 +112,7 @@ "props-physical-name:@aws-cdk/aws-route53.CaaAmazonRecordProps", "props-physical-name:@aws-cdk/aws-route53.CaaRecordProps", "props-physical-name:@aws-cdk/aws-route53.CnameRecordProps", + "props-physical-name:@aws-cdk/aws-route53.DsRecordProps", "props-physical-name:@aws-cdk/aws-route53.HostedZoneProps", "props-physical-name:@aws-cdk/aws-route53.MxRecordProps", "props-physical-name:@aws-cdk/aws-route53.NsRecordProps", diff --git a/packages/@aws-cdk/aws-route53/test/record-set.test.ts b/packages/@aws-cdk/aws-route53/test/record-set.test.ts index a9d5446185f66..ff3a7f6d08c29 100644 --- a/packages/@aws-cdk/aws-route53/test/record-set.test.ts +++ b/packages/@aws-cdk/aws-route53/test/record-set.test.ts @@ -540,6 +540,36 @@ nodeunitShim({ test.done(); }, + 'DS record'(test: Test) { + // GIVEN + const stack = new Stack(); + + const zone = new route53.HostedZone(stack, 'HostedZone', { + zoneName: 'myzone', + }); + + // WHEN + new route53.DsRecord(stack, 'DS', { + zone, + recordName: 'www', + values: ['12345 3 1 123456789abcdef67890123456789abcdef67890'], + }); + + // THEN + expect(stack).to(haveResource('AWS::Route53::RecordSet', { + Name: 'www.myzone.', + Type: 'DS', + HostedZoneId: { + Ref: 'HostedZoneDB99F866', + }, + ResourceRecords: [ + '12345 3 1 123456789abcdef67890123456789abcdef67890', + ], + TTL: '1800', + })); + test.done(); + }, + 'Zone delegation record'(test: Test) { // GIVEN const stack = new Stack();