diff --git a/cdk/bin/cdk.ts b/cdk/bin/cdk.ts index e2c1ba2e8..2d3ac5899 100644 --- a/cdk/bin/cdk.ts +++ b/cdk/bin/cdk.ts @@ -16,6 +16,8 @@ export const notificationCodeProps: NotificationProps = { stage: 'CODE', env: { region: 'eu-west-1' }, domainName: 'notification.notifications.code.dev-guardianapis.com', + intermediateCname: + 'notification.notifications-aws.code.dev-guardianapis.com.', instanceMetricGranularity: '5Minute', workerSqsQueueName: 'mobile-notifications-harvester-CODE-Sqs-1R9TBA4F2C6TG', sloMonitoringQueueName: 'notifications-slo-monitoring-CODE', @@ -28,6 +30,7 @@ export const notificationProdProps: NotificationProps = { stage: 'PROD', env: { region: 'eu-west-1' }, domainName: 'notification.notifications.guardianapis.com', + intermediateCname: 'notification.notifications-aws.guardianapis.com.', instanceMetricGranularity: '1Minute', workerSqsQueueName: 'mobile-notifications-harvester-PROD-Sqs-NPP9X15G7WAO', sloMonitoringQueueName: 'notifications-slo-monitoring-PROD', diff --git a/cdk/lib/__snapshots__/notification.test.ts.snap b/cdk/lib/__snapshots__/notification.test.ts.snap index a9797f8ae..0076509ed 100644 --- a/cdk/lib/__snapshots__/notification.test.ts.snap +++ b/cdk/lib/__snapshots__/notification.test.ts.snap @@ -45,6 +45,7 @@ exports[`The Notification stack matches the snapshot for CODE 1`] = ` "Metadata": { "gu:cdk:constructs": [ "GuStringParameter", + "GuCname", "GuAllowPolicy", "GuAllowPolicy", "GuAllowPolicy", @@ -448,6 +449,18 @@ exports[`The Notification stack matches the snapshot for CODE 1`] = ` }, "Type": "AWS::Route53::RecordSet", }, + "DnsRecordForNotification": { + "Properties": { + "Name": "notification.notifications.code.dev-guardianapis.com", + "RecordType": "CNAME", + "ResourceRecords": [ + "notification.notifications-aws.code.dev-guardianapis.com.", + ], + "Stage": "CODE", + "TTL": 3600, + }, + "Type": "Guardian::DNS::RecordSet", + }, "DynamoDbReportsAccessD5A9D3BB": { "Properties": { "PolicyDocument": { @@ -2234,6 +2247,7 @@ exports[`The Notification stack matches the snapshot for PROD 1`] = ` "Metadata": { "gu:cdk:constructs": [ "GuStringParameter", + "GuCname", "GuAllowPolicy", "GuAllowPolicy", "GuAllowPolicy", @@ -2637,6 +2651,18 @@ exports[`The Notification stack matches the snapshot for PROD 1`] = ` }, "Type": "AWS::Route53::RecordSet", }, + "DnsRecordForNotification": { + "Properties": { + "Name": "notification.notifications.guardianapis.com", + "RecordType": "CNAME", + "ResourceRecords": [ + "notification.notifications-aws.guardianapis.com.", + ], + "Stage": "PROD", + "TTL": 3600, + }, + "Type": "Guardian::DNS::RecordSet", + }, "DynamoDbReportsAccessD5A9D3BB": { "Properties": { "PolicyDocument": { diff --git a/cdk/lib/notification.ts b/cdk/lib/notification.ts index 177f32af8..6fc6f30f6 100644 --- a/cdk/lib/notification.ts +++ b/cdk/lib/notification.ts @@ -9,6 +9,7 @@ import { GuStringParameter, GuVpcParameter, } from '@guardian/cdk/lib/constructs/core'; +import { GuCname } from '@guardian/cdk/lib/constructs/dns'; import { GuAllowPolicy } from '@guardian/cdk/lib/constructs/iam'; import type { App } from 'aws-cdk-lib'; import { Duration, Tags } from 'aws-cdk-lib'; @@ -22,7 +23,9 @@ export interface NotificationProps extends GuStackProps { domainName: | 'notification.notifications.guardianapis.com' | 'notification.notifications.code.dev-guardianapis.com'; - + intermediateCname: + | 'notification.notifications-aws.guardianapis.com.' + | 'notification.notifications-aws.code.dev-guardianapis.com.'; instanceMetricGranularity: '1Minute' | '5Minute'; /** * The ARN of the SQS queue consumed by the workers (harvester). @@ -66,6 +69,15 @@ export class Notification extends GuStack { fromSSM: true, }).valueAsString; + new GuCname(this, 'DnsRecordForNotification', { + app, + domainName: props.domainName, + // For now we are still routing traffic via the intermediate CNAME, which points at the legacy ELB. + // To complete the migration, we'll remove this intermediate CNAME and point at playApp.loadBalancer.loadBalancerDnsName. + resourceRecord: props.intermediateCname, + ttl: Duration.seconds(3600), + }); + const reportsTable = Table.fromTableName( this, 'ReportsTable',