-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route53): support CNAME records (#1487)
Adds support for CNAME records via the `CnameRecord` construct. Misc: - `TXTRecord` was renamed to `TxtRecord`. - `hostedZoneNameServers` attribute added to IHostedZone - Made `HostedZone` a concrete (non-abstract) class so it will be compatible with how CloudFormation represents this resource, but left PublicHostedZone and PrivateHostedZone to allow a more strongly-typed experience if you like. Credits for original PR (closes #1420): @MikeBild BREAKING CHANGE: The `route53.TXTRecord` class was renamed to `route53.TxtRecord`.
- Loading branch information
Elad Ben-Israel
authored
Jan 8, 2019
1 parent
471e8eb
commit 17eddd1
Showing
12 changed files
with
341 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Construct } from '@aws-cdk/cdk'; | ||
import { IHostedZone } from '../hosted-zone-ref'; | ||
import { CfnRecordSet } from '../route53.generated'; | ||
import { determineFullyQualifiedDomainName } from './_util'; | ||
|
||
export interface CnameRecordProps { | ||
/** | ||
* The hosted zone in which to define the new TXT record. | ||
*/ | ||
zone: IHostedZone; | ||
|
||
/** | ||
* The domain name for this record set. | ||
*/ | ||
recordName: string; | ||
|
||
/** | ||
* The value for this record set. | ||
*/ | ||
recordValue: string; | ||
|
||
/** | ||
* The resource record cache time to live (TTL) in seconds. | ||
* | ||
* @default 1800 seconds | ||
*/ | ||
ttl?: number; | ||
} | ||
|
||
/** | ||
* A DNS CNAME record | ||
*/ | ||
export class CnameRecord extends Construct { | ||
constructor(scope: Construct, id: string, props: CnameRecordProps) { | ||
super(scope, id); | ||
|
||
const ttl = props.ttl === undefined ? 1800 : props.ttl; | ||
|
||
new CfnRecordSet(this, 'Resource', { | ||
hostedZoneId: props.zone.hostedZoneId, | ||
name: determineFullyQualifiedDomainName(props.recordName, props.zone), | ||
type: 'CNAME', | ||
resourceRecords: [ props.recordValue ], | ||
ttl: ttl.toString(), | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './alias'; | ||
export * from './txt'; | ||
export * from './cname'; | ||
export * from './zone-delegation'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.