-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from coltenkrauter/development
Add DNS stack
- Loading branch information
Showing
5 changed files
with
99 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
{} | ||
{ | ||
"hosted-zone:account=775126750502:domainName=rememberval.com:region=us-east-1": { | ||
"Id": "/hostedzone/Z10280523GOIQ59UKGL5W", | ||
"Name": "rememberval.com." | ||
} | ||
} |
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,73 @@ | ||
import { Certificate, CertificateValidation } from 'aws-cdk-lib/aws-certificatemanager'; | ||
import { Construct } from 'constructs'; | ||
import { HostedZone, ARecord, RecordTarget, CnameRecord, NsRecord } from 'aws-cdk-lib/aws-route53'; | ||
import { Metric } from 'aws-cdk-lib/aws-cloudwatch'; | ||
import { Route53RecordTarget } from 'aws-cdk-lib/aws-route53-targets'; | ||
import { Stack, StackProps, Duration, CfnOutput, RemovalPolicy } from 'aws-cdk-lib'; | ||
|
||
import { Config } from '../config'; | ||
|
||
interface DNSProps extends StackProps { | ||
config: Config; | ||
} | ||
|
||
export class DNS extends Stack { | ||
readonly zoneId; | ||
constructor(scope: Construct, id: string, props: DNSProps) { | ||
super(scope, id, props); | ||
|
||
// DNS & certs | ||
const zone = new HostedZone(this, `${props.config.codenameCapitalized}HostedZone`, { | ||
zoneName: props.config.domainBase, | ||
}); | ||
zone.applyRemovalPolicy(RemovalPolicy.DESTROY); | ||
|
||
this.zoneId = zone.hostedZoneId; | ||
const metric = new Metric({ | ||
namespace: 'AWS/Route53', | ||
metricName: 'DNSQueries', | ||
dimensionsMap: { | ||
HostedZoneId: zone.hostedZoneId, | ||
} | ||
}); | ||
|
||
// const record =vnew ARecord(this, 'AliasRecord', { | ||
// zone, | ||
// target: RecordTarget.fromAlias(new Route53RecordTarget(props.config.domainBase), | ||
// deleteExisting: true, | ||
// ttl: Duration.minutes(5), | ||
// }); | ||
// record.applyRemovalPolicy(RemovalPolicy.DESTROY); | ||
|
||
// const cname = new CnameRecord(this, `${props.config.stage}CnameRecord`, { | ||
// recordName: props.config.stage, | ||
// zone, | ||
// domainName: props.config.domainBase, | ||
// deleteExisting: true, | ||
// ttl: Duration.minutes(5), | ||
// }); | ||
// cname.applyRemovalPolicy(RemovalPolicy.DESTROY); | ||
|
||
// const ns = new NsRecord(this, 'NSRecord', { | ||
// zone, | ||
// recordName: props.config.domainBase, | ||
// values: [ | ||
// // Get these from the AWS > Route53 > Registered domains > <domain_name> > Name servers | ||
// 'ns-1214.awsdns-23.org.', | ||
// 'ns-191.awsdns-23.com.', | ||
// 'ns-1640.awsdns-13.co.uk.', | ||
// 'ns-790.awsdns-34.net.', | ||
// ], | ||
// deleteExisting: true, | ||
// ttl: Duration.minutes(5), | ||
// }); | ||
// ns.applyRemovalPolicy(RemovalPolicy.DESTROY); | ||
|
||
// const certificate = new Certificate(this, `${id}Certificate`, { | ||
// domainName: props.config.domainBase, | ||
// subjectAlternativeNames: [`www.${props.config.domainBase}`], | ||
// validation: CertificateValidation.fromDns(zone), | ||
// }); | ||
// certificate.applyRemovalPolicy(RemovalPolicy.DESTROY); | ||
} | ||
} |
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