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
14 changes: 14 additions & 0 deletions org-formation/800-redirects/_tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,17 @@ TreatAdApexRedirect:
TargetDomainName: "treatad.org"
AcmCertificateArn: "arn:aws:acm:us-east-1:797640923903:certificate/e8e438c6-8b58-4c39-b63d-d9c2a051e068"
RedirectFctName: !Sub '${resourcePrefix}-treatad-apex-redirect-cloudfront-fct'

# Issue IT-4466, redirect www.cancercomplexity.synapse.org to cancercomplexity.synapse.org
# This requires manually adding a CNAME record in the synapse.org hosted zone
CancerComplexityWebRedirect:
Type: update-stacks
Template: s3-redirect-bucket.yaml
StackName: !Sub '${resourcePrefix}-cancer-complexity-web-redirect'
StackDescription: Setup a redirect from www.cancercomplexity.synapse.org to cancercomplexity.synapse.org
DefaultOrganizationBindingRegion: !Ref primaryRegion
DefaultOrganizationBinding:
Account: !Ref SageITAccount
Parameters:
RedirectFrom: www.cancercomplexity.synapse.org
RedirectTo: cancercomplexity.synapse.org
56 changes: 56 additions & 0 deletions org-formation/800-redirects/s3-redirect-bucket.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Setup a static website bucket for the sole purpose of
# redirecting all request to another website.
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Provision a S3 website with redirect rules
Parameters:
RedirectFrom:
Description: Domain name of the old website (redirected from)
Type: String
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
ConstraintDescription: must be a valid DNS zone name.
RedirectTo:
Description: Domain name of the new website (redirected to)
Type: String
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
ConstraintDescription: must be a valid DNS zone name.
Resources:
WebsiteBucket:
Type: AWS::S3::Bucket
Metadata:
cfn-lint:
config:
ignore_checks: [W3045]
Properties:
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false
IgnorePublicAcls: false
RestrictPublicBuckets: false
BucketName: !Ref RedirectFrom
WebsiteConfiguration:
RedirectAllRequestsTo:
HostName: !Ref RedirectTo
Protocol: https
WebsiteBucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket: !Ref WebsiteBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal: '*'
Action: 's3:GetObject'
Resource: !Sub '${WebsiteBucket.Arn}/*'
Outputs:
BucketWebsiteUrl:
Value: !GetAtt WebsiteBucket.WebsiteURL
Description: URL for website redirector
Export:
Name: !Sub '${AWS::StackName}-BucketWebsiteUrl'
WebsiteBucket:
Value: !Ref WebsiteBucket
Description: The bucket containing the website redirect rules
Export:
Name: !Sub '${AWS::StackName}-WebsiteBucket'