From 463c7d1703607bb34dd574d016fa62528ae5e05c Mon Sep 17 00:00:00 2001 From: Mike Bild Date: Fri, 21 Dec 2018 11:45:35 +0100 Subject: [PATCH] feat(aws-route53): add CNAME record type --- .../@aws-cdk/aws-route53/lib/records/cname.ts | 33 +++++++++++++++++++ .../@aws-cdk/aws-route53/lib/records/index.ts | 1 + 2 files changed, 34 insertions(+) create mode 100644 packages/@aws-cdk/aws-route53/lib/records/cname.ts diff --git a/packages/@aws-cdk/aws-route53/lib/records/cname.ts b/packages/@aws-cdk/aws-route53/lib/records/cname.ts new file mode 100644 index 0000000000000..63b00b92f8761 --- /dev/null +++ b/packages/@aws-cdk/aws-route53/lib/records/cname.ts @@ -0,0 +1,33 @@ +import { Construct } from '@aws-cdk/cdk'; +import { HostedZoneRef } from '../hosted-zone-ref'; +import { CfnRecordSet } from '../route53.generated'; +import { determineFullyQualifiedDomainName } from './_util'; + +export interface CNAMERecordProps { + recordName: string; + recordValue: string; + /** @default 1800 seconds */ + ttl?: number; +} + +/** + * A DNS CNAME record + */ +export class CNAMERecord extends Construct { + constructor(parent: HostedZoneRef, name: string, props: CNAMERecordProps) { + super(parent, name); + + const ttl = props.ttl === undefined ? 1800 : props.ttl; + + new CfnRecordSet(this, 'Resource', { + hostedZoneId: parent.hostedZoneId, + name: determineFullyQualifiedDomainName(props.recordName, parent), + type: 'CNAME', + resourceRecords: + [ + props.recordValue, + ], + ttl: ttl.toString(), + }); + } +} diff --git a/packages/@aws-cdk/aws-route53/lib/records/index.ts b/packages/@aws-cdk/aws-route53/lib/records/index.ts index 655c84bf4ca70..1643af3bdaadb 100644 --- a/packages/@aws-cdk/aws-route53/lib/records/index.ts +++ b/packages/@aws-cdk/aws-route53/lib/records/index.ts @@ -1,3 +1,4 @@ export * from './alias'; export * from './txt'; +export * from './cname'; export * from './zone-delegation';