skip to Main Content

I upload my html code to S3 and enable the static website option. It works fine only for /index.html

If I navigate to an html file like products/index.html it works fine, but when I navigate to the folder like products/ it fails with AccessDenied.

What is the problem? It should recognise the index.html from inside the folder

{
    "Version": "2012-10-17",
    "Id": "__POLICYID__",
    "Statement": [
        {
            "Sid": "__SSID__",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::__MYDOMAIN__/*"
        }
    ]
}

2

Answers


  1. Chosen as BEST ANSWER

    Finally this the solution is a lambda@edge thath replace any path finished with / for path/index.html

    https://aws.amazon.com/blogs/compute/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-lambdaedge/


  2. The issue lies in how S3 static website hosting handles folder paths and index.html files within subdirectories.

    in order to make S3 recognize index.html for folder paths, you need to configure the Default Root Object or ensure that the website hosting settings handle index.html for subdirectories. you can find that Under Static Website Hosting with the Properties Tab, ensure the Index Document is set to index.html. This setting tells S3 to serve index.html when a folder path is accessed.

    like that when you navigate to https://<bucket-name>.s3-website-<region>.amazonaws.com/products/ it should work fine.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search