-
Notifications
You must be signed in to change notification settings - Fork 6
feat(registration): Bring second NS1 CNAME record into CloudFormation #1669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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, | ||||||||
|
|
@@ -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) { | ||||||||
| // The YAML template defines this parameter | ||||||||
| const route53Domain = this.parameters['DomainName']; | ||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See mobile-n10n/registration/conf/registration.yaml Lines 75 to 77 in c2e01cb
|
||||||||
|
|
||||||||
| 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), | ||||||||
| }); | ||||||||
| } | ||||||||
| } | ||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!