Skip to content

Commit

Permalink
Update zoneId
Browse files Browse the repository at this point in the history
  • Loading branch information
Colten Krauter committed Sep 6, 2022
1 parent ba49890 commit c5c9909
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions cdk/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const main = async () => {
analyticsReporting: true,
description: 'The Next stack',
config,
zoneId: dNSStack.zoneId,
}).addDependency(dNSStack);
};

Expand Down
2 changes: 0 additions & 2 deletions cdk/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export interface Config {
stage: string;
topicBounceComplaintEmail: string;
topicBounceComplaintName: string;
zoneId: string;
}

export const getConfig = () => {
Expand Down Expand Up @@ -128,6 +127,5 @@ export const getConfig = () => {
stage,
topicBounceComplaintEmail: `${topicBounceComplaintEmail[stage]}`,
topicBounceComplaintName: `${prefixCamelCase}BounceComplaint`,
zoneId: `${codenameCapitalized}HostedZone`,
};
};
11 changes: 6 additions & 5 deletions cdk/stacks/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ interface DNSProps extends StackProps {
}

export class DNS extends Stack {
readonly zone;
readonly zoneId;
constructor(scope: Construct, id: string, props: DNSProps) {
super(scope, id, props);

// DNS & certs
this.zone = new HostedZone(this, props.config.zoneId, {
const zone = new HostedZone(this, `${props.config.codenameCapitalized}HostedZone`, {
zoneName: props.config.domainBase,
});
this.zone.applyRemovalPolicy(RemovalPolicy.DESTROY);

zone.applyRemovalPolicy(RemovalPolicy.DESTROY);

this.zoneId = zone.hostedZoneId;
const metric = new Metric({
namespace: 'AWS/Route53',
metricName: 'DNSQueries',
dimensionsMap: {
HostedZoneId: this.zone.hostedZoneId,
HostedZoneId: zone.hostedZoneId,
}
});

Expand Down
5 changes: 3 additions & 2 deletions cdk/stacks/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import { Config } from '../config';

interface NextProps extends StackProps {
config: Config;
zoneId: string;
}

export class Next extends Stack {
constructor(scope: Construct, id: string, props: NextProps) {
super(scope, id, props);

// DNS & certs
const zone = HostedZone.fromHostedZoneAttributes(this, props.config.zoneId, {
const zone = HostedZone.fromHostedZoneAttributes(this, props.zoneId, {
zoneName: props.config.domainBase,
hostedZoneId: props.config.zoneId,
hostedZoneId: props.zoneId,
});

const certificate = new Certificate(this, `${id}Certificate`, {
Expand Down

0 comments on commit c5c9909

Please sign in to comment.