Skip to content

Commit 0ebfa51

Browse files
authored
Revert "Revert "[IT-4466] Redirect website (#1464)" (#1469)" (#1470)
This reverts commit 270a1dc. This is a second attempt at PR #1464
1 parent 0b6893d commit 0ebfa51

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

org-formation/800-redirects/_tasks.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,17 @@ TreatAdApexRedirect:
422422
TargetDomainName: "treatad.org"
423423
AcmCertificateArn: "arn:aws:acm:us-east-1:797640923903:certificate/e8e438c6-8b58-4c39-b63d-d9c2a051e068"
424424
RedirectFctName: !Sub '${resourcePrefix}-treatad-apex-redirect-cloudfront-fct'
425+
426+
# Issue IT-4466, redirect www.cancercomplexity.synapse.org to cancercomplexity.synapse.org
427+
# This requires manually adding a CNAME record in the synapse.org hosted zone
428+
CancerComplexityWebRedirect:
429+
Type: update-stacks
430+
Template: s3-redirect-bucket.yaml
431+
StackName: !Sub '${resourcePrefix}-cancer-complexity-web-redirect'
432+
StackDescription: Setup a redirect from www.cancercomplexity.synapse.org to cancercomplexity.synapse.org
433+
DefaultOrganizationBindingRegion: !Ref primaryRegion
434+
DefaultOrganizationBinding:
435+
Account: !Ref SageITAccount
436+
Parameters:
437+
RedirectFrom: www.cancercomplexity.synapse.org
438+
RedirectTo: cancercomplexity.synapse.org
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Setup a static website bucket for the sole purpose of
2+
# redirecting all request to another website.
3+
AWSTemplateFormatVersion: 2010-09-09
4+
Description: >-
5+
Provision a S3 website with redirect rules
6+
Parameters:
7+
RedirectFrom:
8+
Description: Domain name of the old website (redirected from)
9+
Type: String
10+
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
11+
ConstraintDescription: must be a valid DNS zone name.
12+
RedirectTo:
13+
Description: Domain name of the new website (redirected to)
14+
Type: String
15+
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
16+
ConstraintDescription: must be a valid DNS zone name.
17+
Resources:
18+
WebsiteBucket:
19+
Type: AWS::S3::Bucket
20+
Metadata:
21+
cfn-lint:
22+
config:
23+
ignore_checks: [W3045]
24+
Properties:
25+
PublicAccessBlockConfiguration:
26+
BlockPublicAcls: false
27+
BlockPublicPolicy: false
28+
IgnorePublicAcls: false
29+
RestrictPublicBuckets: false
30+
BucketName: !Ref RedirectFrom
31+
WebsiteConfiguration:
32+
RedirectAllRequestsTo:
33+
HostName: !Ref RedirectTo
34+
Protocol: https
35+
WebsiteBucketPolicy:
36+
Type: 'AWS::S3::BucketPolicy'
37+
Properties:
38+
Bucket: !Ref WebsiteBucket
39+
PolicyDocument:
40+
Version: '2012-10-17'
41+
Statement:
42+
- Effect: Allow
43+
Principal: '*'
44+
Action: 's3:GetObject'
45+
Resource: !Sub '${WebsiteBucket.Arn}/*'
46+
Outputs:
47+
BucketWebsiteUrl:
48+
Value: !GetAtt WebsiteBucket.WebsiteURL
49+
Description: URL for website redirector
50+
Export:
51+
Name: !Sub '${AWS::StackName}-BucketWebsiteUrl'
52+
WebsiteBucket:
53+
Value: !Ref WebsiteBucket
54+
Description: The bucket containing the website redirect rules
55+
Export:
56+
Name: !Sub '${AWS::StackName}-WebsiteBucket'

0 commit comments

Comments
 (0)