Skip to content

Commit 6414759

Browse files
authored
Start managing report's NS1 CNAME via GuCDK (#1591)
1 parent ffb3de9 commit 6414759

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

cdk/bin/cdk.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const reportPropsCode: ReportProps = {
7474
stage: 'CODE',
7575
app: 'report',
7676
domainName: 'report.notifications.code.dev-guardianapis.com',
77+
intermediateCname: 'report.notifications-aws.code.dev-guardianapis.com.',
7778
instanceMetricGranularity: '5Minute',
7879
loggingStreamParameterName: '/account/services/logging.stream.name.code',
7980
minAsgSize: 1,
@@ -87,6 +88,7 @@ export const reportPropsProd: ReportProps = {
8788
stage: 'PROD',
8889
app: 'report',
8990
domainName: 'report.notifications.guardianapis.com',
91+
intermediateCname: 'report.notifications-aws.guardianapis.com.',
9092
instanceMetricGranularity: '1Minute',
9193
loggingStreamParameterName: '/account/services/logging.stream.name',
9294
minAsgSize: 3,

cdk/lib/__snapshots__/report.test.ts.snap

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ exports[`The Report stack matches the snapshot for CODE 1`] = `
4848
"GuAccessLoggingBucketParameter",
4949
"GuApplicationTargetGroup",
5050
"GuHttpsApplicationListener",
51+
"GuCname",
5152
],
5253
"gu:cdk:version": "TEST",
5354
},
@@ -354,6 +355,18 @@ exports[`The Report stack matches the snapshot for CODE 1`] = `
354355
},
355356
"Type": "AWS::Route53::RecordSet",
356357
},
358+
"DnsRecordForReport": {
359+
"Properties": {
360+
"Name": "report.notifications.code.dev-guardianapis.com",
361+
"RecordType": "CNAME",
362+
"ResourceRecords": [
363+
"report.notifications-aws.code.dev-guardianapis.com.",
364+
],
365+
"Stage": "CODE",
366+
"TTL": 3600,
367+
},
368+
"Type": "Guardian::DNS::RecordSet",
369+
},
357370
"DynamoDbAccess14AC0B35": {
358371
"Properties": {
359372
"PolicyDocument": {
@@ -1498,6 +1511,7 @@ exports[`The Report stack matches the snapshot for PROD 1`] = `
14981511
"GuAccessLoggingBucketParameter",
14991512
"GuApplicationTargetGroup",
15001513
"GuHttpsApplicationListener",
1514+
"GuCname",
15011515
],
15021516
"gu:cdk:version": "TEST",
15031517
},
@@ -1804,6 +1818,18 @@ exports[`The Report stack matches the snapshot for PROD 1`] = `
18041818
},
18051819
"Type": "AWS::Route53::RecordSet",
18061820
},
1821+
"DnsRecordForReport": {
1822+
"Properties": {
1823+
"Name": "report.notifications.guardianapis.com",
1824+
"RecordType": "CNAME",
1825+
"ResourceRecords": [
1826+
"report.notifications-aws.guardianapis.com.",
1827+
],
1828+
"Stage": "PROD",
1829+
"TTL": 3600,
1830+
},
1831+
"Type": "Guardian::DNS::RecordSet",
1832+
},
18071833
"DynamoDbAccess14AC0B35": {
18081834
"Properties": {
18091835
"PolicyDocument": {

cdk/lib/report.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { GuVpcParameter } from '@guardian/cdk/lib/constructs/core';
66
import { GuLoggingStreamNameParameter } from '@guardian/cdk/lib/constructs/core';
77
import { GuDistributionBucketParameter } from '@guardian/cdk/lib/constructs/core';
88
import { GuStack } from '@guardian/cdk/lib/constructs/core';
9+
import { GuCname } from '@guardian/cdk/lib/constructs/dns';
910
import { GuAllowPolicy } from '@guardian/cdk/lib/constructs/iam';
1011
import type { App } from 'aws-cdk-lib';
1112
import { Tags } from 'aws-cdk-lib';
@@ -18,6 +19,10 @@ export interface ReportProps extends GuStackProps {
1819
domainName:
1920
| 'report.notifications.guardianapis.com'
2021
| 'report.notifications.code.dev-guardianapis.com';
22+
// This maps to the DnsRecord resource in Route53; we can remove this complexity as part of the DNS switchover
23+
intermediateCname:
24+
| 'report.notifications-aws.guardianapis.com.'
25+
| 'report.notifications-aws.code.dev-guardianapis.com.';
2126
instanceMetricGranularity: '1Minute' | '5Minute';
2227
loggingStreamParameterName:
2328
| '/account/services/logging.stream.name'
@@ -141,5 +146,14 @@ export class Report extends GuStack {
141146
GuLoggingStreamNameParameter.getInstance(this);
142147
loggingStreamParameter.allowedValues = [props.loggingStreamParameterName];
143148
loggingStreamParameter.default = props.loggingStreamParameterName;
149+
150+
new GuCname(this, 'DnsRecordForReport', {
151+
app,
152+
domainName: props.domainName,
153+
// For now we are still routing traffic via the intermediate CNAME, which points at the legacy ELB.
154+
// To complete the migration, we'll remove this intermediate CNAME and point at playApp.loadBalancer.loadBalancerDnsName.
155+
resourceRecord: props.intermediateCname,
156+
ttl: Duration.seconds(3600),
157+
});
144158
}
145159
}

0 commit comments

Comments
 (0)