Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions cdk/lib/__snapshots__/registration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
"GuHttpsApplicationListener",
"GuParameter",
"GuCname",
"GuCname",
],
"gu:cdk:version": "TEST",
},
Expand Down Expand Up @@ -1433,6 +1434,20 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
},
"Type": "AWS::CloudWatch::Alarm",
},
"NS1ToRoute53Record": {
"Properties": {
"Name": "registration.notifications.code.dev-guardianapis.com",
"RecordType": "CNAME",
"ResourceRecords": [
{
"Ref": "DomainName",
},
],
"Stage": "CODE",
"TTL": 3600,
},
"Type": "Guardian::DNS::RecordSet",
},
"NotEnoughHttpCode200sAlarm": {
"Properties": {
"AlarmActions": [
Expand Down Expand Up @@ -2062,6 +2077,7 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
"GuHttpsApplicationListener",
"GuParameter",
"GuCname",
"GuCname",
],
"gu:cdk:version": "TEST",
},
Expand Down Expand Up @@ -3437,6 +3453,20 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
},
"Type": "AWS::CloudWatch::Alarm",
},
"NS1ToRoute53Record": {
"Properties": {
"Name": "registration.notifications.guardianapis.com",
"RecordType": "CNAME",
"ResourceRecords": [
{
"Ref": "DomainName",
},
],
"Stage": "PROD",
"TTL": 3600,
},
"Type": "Guardian::DNS::RecordSet",
},
"NotEnoughHttpCode200sAlarm": {
"Properties": {
"AlarmActions": [
Expand Down
48 changes: 48 additions & 0 deletions cdk/lib/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export class Registration extends GuStack {

adjustCloudformationParameters(this);

// This CNAME represents the public URL for the registration service.
new GuCname(this, 'DnsRecordForRegistration', {
app,
domainName: props.domainName,
Expand All @@ -180,5 +181,52 @@ export class Registration extends GuStack {
resourceRecord: props.intermediateCname,
ttl: Duration.seconds(props.intermediateCnameTTLInSeconds),
});

this.addLegacyCname(props);
}

/**
* Using `dig` we can see the following DNS setup:
*
* ```bash
* ❯ dig +nocmd +noall +answer notifications.guardianapis.com
* notifications.guardianapis.com. 7200 IN CNAME registration.notifications.guardianapis.com.
* registration.notifications.guardianapis.com. 3600 IN CNAME registration.notifications-aws.guardianapis.com.
* registration.notifications-aws.guardianapis.com. 60 IN CNAME mobile-no-loadbala-1oljehvjszyof-880073426.eu-west-1.elb.amazonaws.com.
* ```
*
* That is:
* 1. `notifications.guardianapis.com.` is in NS1
* 2. `registration.notifications.guardianapis.com.` is in NS1
* 3. `registration.notifications-aws.guardianapis.com.` is in Route53
* 4. `mobile-no-loadbala-1oljehvjszyof-880073426.eu-west-1.elb.amazonaws.com.` is the AWS Load Balancer
*
* After the GuCDK migration, we'll simplify DNS to have:
*
* `notifications.guardianapis.com.` (NS1) -> AWS Load Balancer
*
* That is 1 -> 4.
*
* This resource represents the CNAME for 2 -> 3.
* Defining it here means we can delete it later via a CloudFormation update.
*
* @todo Remove this once the GuCDK-defined load balancer is being used
*
* @see https://metrics.gutools.co.uk/goto/zF4xr1HvR?orgId=1
*/
private addLegacyCname({ app, intermediateCname }: RegistrationProps) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely convinced about this function name, however it is only temporary. Suggestions for a clearer name welcomed!

// The YAML template defines this parameter
const route53Domain = this.parameters['DomainName'];

@akash1810 akash1810 Feb 2, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See

DomainName:
Type: String
Description: The domain name of the ELB, should contain the trailing dot stuff.zone.example.com.
for the YAML template and https://metrics.gutools.co.uk/goto/xVMwCJHDg?orgId=1 for the value of the parameter as deployed.


if (!route53Domain) {
throw new Error('Unable to locate CloudFormation parameter "DomainName"');
}

new GuCname(this, 'NS1ToRoute53Record', {
app,
domainName: intermediateCname.slice(0, -1), // Remove trailing dot to exactly match CNAME in NS1
resourceRecord: route53Domain.valueAsString,
ttl: Duration.seconds(3600),
});
}
}