If you've enabled static site hosting and assigned origin access identity with enough permissions to view everything in the bucket. In Terraform, it would look something like this:
resource "aws_cloudfront_origin_access_identity" "website_oai" {
comment = join("", ["Origin access identity of ", var.project_name, " Cloudfront."])
}
data "aws_iam_policy_document" "website_s3_iam_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.website_bucket.arn}/*"]
principals {
type = "AWS"
identifiers = [aws_cloudfront_origin_access_identity.website_oai.iam_arn]
}
}
}
If providing permissions to all the objects inside the bucket does not work,
It seems that you will have to configure a redirection rule on S3 itself. Here is a link that shares at least 3 steps to do this.
To configure redirection rules for a static website and add redirection rules for a bucket that already has static website hosting enabled, follow these steps.
Open the Amazon S3 console at https://console.aws.amazon.com/s3/.
In the Buckets list, choose the name of a bucket that you have configured as a static website.
Choose Properties.
Under Static website hosting, choose Edit.
In Redirection rules box, enter your redirection rules in JSON.
In the S3 console you describe the rules using JSON. For JSON examples, see Redirection rules examples. Amazon S3 has a limitation of 50 routing rules per website configuration.
Recommending the layering of your automation by separating provisioning and application automation by using Terraform or/and Cloud Formation for this.
INVEST
. It then linked to:https://somaloans.com/invest/
What object do you have in that path that should be displayed -- is itinvest/index.html
? If so, did you configure the index document when Enabling website hosting?http://your-bucket-name.s3-website.us-west-2.amazonaws.com/invest/index.html
) is the page displayed?/invest
? Is itinvest/index.html
that should be displayed?