Skip to content

Commit 842c1cb

Browse files
authored
Merge pull request #1672 from guardian/simplify-registration-dns
feat(registration): Update reader facing CNAME to point directly at load balancer
2 parents edb360e + 846ea9b commit 842c1cb

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,12 @@ exports[`The Registration stack matches the snapshot for CODE 1`] = `
600600
"Name": "notifications.code.dev-guardianapis.com",
601601
"RecordType": "CNAME",
602602
"ResourceRecords": [
603-
"registration.notifications.code.dev-guardianapis.com.",
603+
{
604+
"Fn::GetAtt": [
605+
"LoadBalancerToPrivateASG",
606+
"DNSName",
607+
],
608+
},
604609
],
605610
"Stage": "CODE",
606611
"TTL": 60,
@@ -2619,7 +2624,12 @@ exports[`The Registration stack matches the snapshot for PROD 1`] = `
26192624
"Name": "notifications.guardianapis.com",
26202625
"RecordType": "CNAME",
26212626
"ResourceRecords": [
2622-
"registration.notifications.guardianapis.com.",
2627+
{
2628+
"Fn::GetAtt": [
2629+
"LoadBalancerToPrivateASG",
2630+
"DNSName",
2631+
],
2632+
},
26232633
],
26242634
"Stage": "PROD",
26252635
"TTL": 60,

cdk/lib/registration.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
InstanceType,
1919
SecurityGroup,
2020
} from 'aws-cdk-lib/aws-ec2';
21+
import type { CfnLoadBalancer } from 'aws-cdk-lib/aws-elasticloadbalancing';
2122
import { HttpCodeTarget } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
2223
import { Topic } from 'aws-cdk-lib/aws-sns';
2324
import { CfnInclude } from 'aws-cdk-lib/cloudformation-include';
@@ -48,7 +49,7 @@ export class Registration extends GuStack {
4849
// Until this project has been fully migrated to GuCDK you should update the 'old' infrastructure by modifying
4950
// the YAML file and then re-running the snapshot tests to confirm that the changes are being pulled through by
5051
// CDK
51-
new CfnInclude(this, 'YamlTemplate', {
52+
const template = new CfnInclude(this, 'YamlTemplate', {
5253
templateFile: yamlTemplateFilePath,
5354
});
5455

@@ -171,13 +172,17 @@ export class Registration extends GuStack {
171172

172173
adjustCloudformationParameters(this);
173174

175+
const legacyLoadBalancer = template.getResource(
176+
'LoadBalancerToPrivateASG',
177+
) as CfnLoadBalancer;
178+
174179
// This CNAME represents the public URL for the registration service.
175180
new GuCname(this, 'DnsRecordForRegistration', {
176181
app,
177182
domainName: props.domainName,
178-
// For now we are still routing traffic via the intermediate CNAME, which points at the legacy ELB.
179-
// To complete the migration, we'll remove this intermediate CNAME and point at playApp.loadBalancer.loadBalancerDnsName.
180-
resourceRecord: props.intermediateCname,
183+
// For now we are still routing traffic to the legacy ELB.
184+
// To complete the migration, we'll update to point at playApp.loadBalancer.loadBalancerDnsName.
185+
resourceRecord: legacyLoadBalancer.attrDnsName,
181186

182187
// Intentionally low TTL for faster DNS changes
183188
// TODO increase this to 7200 (2 hours) after the migration is complete

0 commit comments

Comments
 (0)