Skip to content

Commit 8c508b8

Browse files
authored
Merge pull request #1675 from guardian/rm-extra-registration-dns
feat(registration): Remove redundant CNAMEs
2 parents 842c1cb + 1462b9e commit 8c508b8

4 files changed

Lines changed: 0 additions & 151 deletions

File tree

cdk/bin/cdk.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export const registrationCodeProps: RegistrationProps = {
5252
{ period: Duration.hours(24), threshold: 1 },
5353
],
5454
cloudFormationStackName: 'mobile-notifications-registration-CODE',
55-
intermediateCname: 'registration.notifications.code.dev-guardianapis.com.',
5655
};
5756

5857
export const registrationProdProps: RegistrationProps = {
@@ -69,7 +68,6 @@ export const registrationProdProps: RegistrationProps = {
6968
{ period: Duration.hours(24), threshold: 150_000 },
7069
],
7170
cloudFormationStackName: 'mobile-notifications-registration-PROD',
72-
intermediateCname: 'registration.notifications.guardianapis.com.',
7371
};
7472

7573
new Registration(app, 'Registration-CODE', registrationCodeProps);

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

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
5858
"GuHttpsApplicationListener",
5959
"GuParameter",
6060
"GuCname",
61-
"GuCname",
6261
],
6362
"gu:cdk:version": "TEST",
6463
},
@@ -128,14 +127,6 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
128127
"Description": "SSM parameter containing the S3 bucket name holding distribution artifacts",
129128
"Type": "AWS::SSM::Parameter::Value<String>",
130129
},
131-
"DomainName": {
132-
"Description": "The domain name of the ELB, should contain the trailing dot stuff.zone.example.com.",
133-
"Type": "String",
134-
},
135-
"HostedZone": {
136-
"Description": "The HostedZone, should contain the trailing dot zone.example.com.",
137-
"Type": "String",
138-
},
139130
"LegacyLoggingStreamName": {
140131
"AllowedValues": [
141132
"/account/services/logging.stream.name.code",
@@ -577,24 +568,6 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
577568
},
578569
"Type": "AWS::IAM::Role",
579570
},
580-
"DnsRecord": {
581-
"Properties": {
582-
"HostedZoneName": {
583-
"Ref": "HostedZone",
584-
},
585-
"Name": {
586-
"Ref": "DomainName",
587-
},
588-
"ResourceRecords": [
589-
{
590-
"Fn::GetAtt": "LoadBalancerToPrivateASG.DNSName",
591-
},
592-
],
593-
"TTL": "60",
594-
"Type": "CNAME",
595-
},
596-
"Type": "AWS::Route53::RecordSet",
597-
},
598571
"DnsRecordForRegistration": {
599572
"Properties": {
600573
"Name": "notifications.code.dev-guardianapis.com",
@@ -1439,20 +1412,6 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
14391412
},
14401413
"Type": "AWS::CloudWatch::Alarm",
14411414
},
1442-
"NS1ToRoute53Record": {
1443-
"Properties": {
1444-
"Name": "registration.notifications.code.dev-guardianapis.com",
1445-
"RecordType": "CNAME",
1446-
"ResourceRecords": [
1447-
{
1448-
"Ref": "DomainName",
1449-
},
1450-
],
1451-
"Stage": "CODE",
1452-
"TTL": 3600,
1453-
},
1454-
"Type": "Guardian::DNS::RecordSet",
1455-
},
14561415
"NotEnoughHttpCode200sAlarm": {
14571416
"Properties": {
14581417
"AlarmActions": [
@@ -2082,7 +2041,6 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
20822041
"GuHttpsApplicationListener",
20832042
"GuParameter",
20842043
"GuCname",
2085-
"GuCname",
20862044
],
20872045
"gu:cdk:version": "TEST",
20882046
},
@@ -2152,14 +2110,6 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
21522110
"Description": "SSM parameter containing the S3 bucket name holding distribution artifacts",
21532111
"Type": "AWS::SSM::Parameter::Value<String>",
21542112
},
2155-
"DomainName": {
2156-
"Description": "The domain name of the ELB, should contain the trailing dot stuff.zone.example.com.",
2157-
"Type": "String",
2158-
},
2159-
"HostedZone": {
2160-
"Description": "The HostedZone, should contain the trailing dot zone.example.com.",
2161-
"Type": "String",
2162-
},
21632113
"LegacyLoggingStreamName": {
21642114
"AllowedValues": [
21652115
"/account/services/logging.stream.name.code",
@@ -2601,24 +2551,6 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
26012551
},
26022552
"Type": "AWS::IAM::Role",
26032553
},
2604-
"DnsRecord": {
2605-
"Properties": {
2606-
"HostedZoneName": {
2607-
"Ref": "HostedZone",
2608-
},
2609-
"Name": {
2610-
"Ref": "DomainName",
2611-
},
2612-
"ResourceRecords": [
2613-
{
2614-
"Fn::GetAtt": "LoadBalancerToPrivateASG.DNSName",
2615-
},
2616-
],
2617-
"TTL": "60",
2618-
"Type": "CNAME",
2619-
},
2620-
"Type": "AWS::Route53::RecordSet",
2621-
},
26222554
"DnsRecordForRegistration": {
26232555
"Properties": {
26242556
"Name": "notifications.guardianapis.com",
@@ -3463,20 +3395,6 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
34633395
},
34643396
"Type": "AWS::CloudWatch::Alarm",
34653397
},
3466-
"NS1ToRoute53Record": {
3467-
"Properties": {
3468-
"Name": "registration.notifications.guardianapis.com",
3469-
"RecordType": "CNAME",
3470-
"ResourceRecords": [
3471-
{
3472-
"Ref": "DomainName",
3473-
},
3474-
],
3475-
"Stage": "PROD",
3476-
"TTL": 3600,
3477-
},
3478-
"Type": "Guardian::DNS::RecordSet",
3479-
},
34803398
"NotEnoughHttpCode200sAlarm": {
34813399
"Properties": {
34823400
"AlarmActions": [

cdk/lib/registration.ts

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ export interface RegistrationProps extends GuStackProps {
2929
domainName:
3030
| 'notifications.guardianapis.com'
3131
| 'notifications.code.dev-guardianapis.com';
32-
// This maps to the DnsRecord resource in Route53; we can remove this complexity as part of the DNS switchover
33-
intermediateCname:
34-
| 'registration.notifications.guardianapis.com.'
35-
| 'registration.notifications.code.dev-guardianapis.com.';
3632
instanceMetricGranularity: '1Minute' | '5Minute';
3733
minAsgSize: number;
3834
maxAsgSize?: number;
@@ -188,52 +184,5 @@ export class Registration extends GuStack {
188184
// TODO increase this to 7200 (2 hours) after the migration is complete
189185
ttl: Duration.minutes(1),
190186
});
191-
192-
this.addLegacyCname(props);
193-
}
194-
195-
/**
196-
* Using `dig` we can see the following DNS setup:
197-
*
198-
* ```bash
199-
* ❯ dig +nocmd +noall +answer notifications.guardianapis.com
200-
* notifications.guardianapis.com. 7200 IN CNAME registration.notifications.guardianapis.com.
201-
* registration.notifications.guardianapis.com. 3600 IN CNAME registration.notifications-aws.guardianapis.com.
202-
* registration.notifications-aws.guardianapis.com. 60 IN CNAME mobile-no-loadbala-1oljehvjszyof-880073426.eu-west-1.elb.amazonaws.com.
203-
* ```
204-
*
205-
* That is:
206-
* 1. `notifications.guardianapis.com.` is in NS1
207-
* 2. `registration.notifications.guardianapis.com.` is in NS1
208-
* 3. `registration.notifications-aws.guardianapis.com.` is in Route53
209-
* 4. `mobile-no-loadbala-1oljehvjszyof-880073426.eu-west-1.elb.amazonaws.com.` is the AWS Load Balancer
210-
*
211-
* After the GuCDK migration, we'll simplify DNS to have:
212-
*
213-
* `notifications.guardianapis.com.` (NS1) -> AWS Load Balancer
214-
*
215-
* That is 1 -> 4.
216-
*
217-
* This resource represents the CNAME for 2 -> 3.
218-
* Defining it here means we can delete it later via a CloudFormation update.
219-
*
220-
* @todo Remove this once the GuCDK-defined load balancer is being used
221-
*
222-
* @see https://metrics.gutools.co.uk/goto/zF4xr1HvR?orgId=1
223-
*/
224-
private addLegacyCname({ app, intermediateCname }: RegistrationProps) {
225-
// The YAML template defines this parameter
226-
const route53Domain = this.parameters['DomainName'];
227-
228-
if (!route53Domain) {
229-
throw new Error('Unable to locate CloudFormation parameter "DomainName"');
230-
}
231-
232-
new GuCname(this, 'NS1ToRoute53Record', {
233-
app,
234-
domainName: intermediateCname.slice(0, -1), // Remove trailing dot to exactly match CNAME in NS1
235-
resourceRecord: route53Domain.valueAsString,
236-
ttl: Duration.seconds(3600),
237-
});
238187
}
239188
}

registration/conf/registration.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,6 @@ Parameters:
6969
DistBucket:
7070
Type: String
7171
Description: The name of the s3 bucket containing the server artifact
72-
HostedZone:
73-
Type: String
74-
Description: The HostedZone, should contain the trailing dot zone.example.com.
75-
DomainName:
76-
Type: String
77-
Description: The domain name of the ELB, should contain the trailing dot stuff.zone.example.com.
7872
NotEnough200sThreshold:
7973
Type: Number
8074
Description: Alarm if less than this many 200s in half an hour
@@ -146,16 +140,6 @@ Resources:
146140
- arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/notifications/${Stage}/${Stack}
147141
- Stack: !FindInMap [Constants, Stack, Value]
148142

149-
DnsRecord:
150-
Type: AWS::Route53::RecordSet
151-
Properties:
152-
HostedZoneName: !Ref HostedZone
153-
Name: !Ref DomainName
154-
ResourceRecords:
155-
- !GetAtt LoadBalancerToPrivateASG.DNSName
156-
TTL: 60
157-
Type: CNAME
158-
159143
HighCPUAlarm:
160144
Type: AWS::CloudWatch::Alarm
161145
Properties:

0 commit comments

Comments
 (0)