cu-mkp / research-teaching-companion

Webpage content and navigation for the Making and Knowing Project's Research and Teaching Companion
1 stars 0 forks source link

reroute RTC site from github.io to teaching640 #15

Open njr2128 opened 5 months ago

njr2128 commented 5 months ago

Through cloudfront?

https://cu-mkp.github.io/research-teaching-companion/

https://teaching640.makingandknowing.org/

njr2128 commented 4 months ago

WAIT until we are ready to release the first public release of the site. Use the github.io site as "dev" or "staging"

njr2128 commented 2 months ago

We have set up a CloudFront distribution, but have encountered errors with accessing site pages from the landing page. This seems to be due to Hugo's index.html needs that are different from AWS

to Everyone https://fastfoodcoding.com/recipes/hugo/hosting-hugo-on-aws-s3-cloudfront/

Terry Catapano 12:33 PM

def lambda_handler(event, context):
    request = event['Records'][0]['cf']['request']
    uri = request['uri']

    # If URL ends with a slash, append index.html
    if uri.endswith('/'):
        request['uri'] += 'index.html'

    return request
njr2128 commented 2 months ago

Another issue just encountered - permissions: image

tcatapano commented 1 month ago

Working now. The function is actually:

def lambda_handler(event, context):
    request = event['Records'][0]['cf']['request']
    uri = request['uri']

    # If URL ends with a slash, append index.html
    if uri.endswith('/'):
        request['uri'] += 'index.html'

    return request

Also, need to publish a version and use that version's ARN in the Lambda Function Association Viewer Request in the 'Behaviors" for the distribution in CloudFront, as well as specifying Path Pattern is* `

Also using IAM Trust Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "lambda.amazonaws.com",
                    "edgelambda.amazonaws.com"
                ]
            },
            "Action": "sts:AssumeRole"
        }
    ]
}