Skip to content

Commit

Permalink
feat: Add support for our new domain names (#344)
Browse files Browse the repository at this point in the history
* Add `taylorchase.net` SAN for website ACM cert

* Add `taylorchase.net` additional CF alias

* Redirect users back to primary domain

* Add additional SAN for `rileychase.au` and `taylorchase.au`

* Add distribution aliases for `rileychase.au` and `taylorchase.au`
  • Loading branch information
Nadock authored Jul 31, 2024
1 parent 4c0d639 commit 3dc7ded
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions aws/acm_cert_cfn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Resources:
Value: rileychase.net
- Key: STAGE
Value: production
SubjectAlternativeNames:
- rileychase.au
- taylorchase.au
- taylorchase.net


Outputs:
Expand Down
26 changes: 24 additions & 2 deletions aws/website_cfn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ Resources:
DistributionConfig:
Aliases:
- !Ref DomainName
# This is not portable, if you're copying this you'll want to remove the
# additional domains below.
- rileychase.au
- taylorchase.net
- taylorchase.au
Comment: !Ref AWS::StackName
CustomErrorResponses:
- ErrorCode: 400
Expand Down Expand Up @@ -191,6 +196,23 @@ Resources:
FunctionCode: |
function handler(event) {
var request = event.request;
// Redirect users on alternate domains back to the primary domain.
var host = event.request.headers.host.value;
if (host !== 'rileychase.net') {
var location = 'https://rileychase.net'
if (!request.uri.startsWith('/')) {
location += '/'
}
location += request.uri
return {
statusCode: 302,
statusDescription: 'Found',
headers: { 'location': { value: location } }
}
}
var uri = request.uri;
var leaf = uri.split("/")[uri.split("/").length - 1];
Expand All @@ -216,14 +238,14 @@ Resources:
AliasTarget:
DNSName: !GetAtt WebsiteDistribution.DomainName
EvaluateTargetHealth: false
# The following HosteZoneId is always used for alias records pointing to CF.
# The following HosteZoneId is always used for alias records pointing to CF.
HostedZoneId: Z2FDTNDATAQYW2
- Name: !Ref DomainName
Type: AAAA
AliasTarget:
DNSName: !GetAtt WebsiteDistribution.DomainName
EvaluateTargetHealth: false
# The following HosteZoneId is always used for alias records pointing to CF.
# The following HosteZoneId is always used for alias records pointing to CF.
HostedZoneId: Z2FDTNDATAQYW2


Expand Down

0 comments on commit 3dc7ded

Please sign in to comment.