0

I'm working on getting a static website deployed with AWS Codebuild, hosted in an S3 bucket, and accessed via Cloudfront. Everything seems to work except from accessing from Cloudfront. From Cloudfront, I can access files that I manually upload, and using the bucket URL, I can access all the files. Looking through the individual file settings/permissions, they all look to be the same, regardless of whether they were manually uploaded, or deployed via Codebuild. I've tried invalidating the Cloudfront cache, and re-deployed via Codebuild several times.


Additional Information:

I provided the S3 bucket as an origin when setting up the Cloudfront distribution.

Accessing via Cloudfront gives the following error:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>0211CBE618946F</RequestId>
<HostId>
7sRZhaJS4x2W7Iaeo4y8KAjvsOJcNWh3PxCdgnhXPE22oyp1RxZhwpjrqbsWapsUSaqBK+jqE=
</HostId>
</Error>

What else should I check?

danwoods
  • 4,889
  • 11
  • 62
  • 90
  • What error code or message do you get when accessing via CloudFront? And how did you provide CloudFront with access to your S3 bucket? – jarmod May 28 '20 at 16:47
  • @jarmod Check the edits to the question – danwoods May 28 '20 at 17:31
  • 1
    How recently did you deploy it? Unless you're using US East (N. Virginia) as your region it'll take a bit of time for the DNS records to be created and propagate for new created S3 buckets - good explanation [in this answer](https://stackoverflow.com/a/58423033/2064596). – Oscar Schafer May 28 '20 at 17:38
  • @OscarSchafer Thanks! It's been deploy since before I tested with a manually uploaded file (which worked fine). – danwoods May 28 '20 at 18:46

1 Answers1

1

enter image description here

For some reason, adding a default root object fixed the issue.

FWIW, I initially changed the value to dist/index.html, which allowed me to access the deployed bucket contents via the Cloudfront URL, but required the index.html suffix. Once I changed it to index.html, everything worked fine.

danwoods
  • 4,889
  • 11
  • 62
  • 90