Skip to content

Commit

Permalink
feat(route-53): add ability to create DS Records (#14726)
Browse files Browse the repository at this point in the history
This PR adds support for DS records.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Infra-Red authored Jun 7, 2021
1 parent aee0f58 commit f0c9726
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/@aws-cdk/aws-route53/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-route53/lib/record-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
*/
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-route53/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 30 additions & 0 deletions packages/@aws-cdk/aws-route53/test/record-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f0c9726

Please sign in to comment.