DEV Community

Cao Duy Khanh
Cao Duy Khanh

Posted on

How to resolve issue Access Denied between S3 and CloudFront

I have setup S3 to store image files and access them through CloudFront. But I have an error Access Denied and link CloudFront was redirect to S3 link as below image:
Alt Text


The root cause of issue relates to โ€œRequests made with the legacy global endpoint go to US East (N. Virginia) by default.โ€

Refer: https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html


To fix this issue, we need to back to setup CloudFront before.
Alt Text
Normally, we will select own s3 bucket which contains static files on dropdown list. In this case, endpoint is format as:<bucket>.s3.amazonaws.com
This endpoint is global endpoint. We need to change to region endpoint then issue will be fixed. The region endpoint format as: <bucket>.s3-<region>.amazonaws.com
Alt Text
The result as below
Alt Text

Discussion (4)

Collapse
osinachiuro profile image
Osinachi-Uro • Edited on

Hi Cao,
I received the message below after i updated the region to us-east-1 and reloaded the page. Any ideas?

Collapse
khanhcd92 profile image
Cao Duy Khanh Author

Hi Osinachi-Uro,

Could you give me message or photo about your issue ?

Collapse
osinachiuro profile image
Osinachi-Uro

It worked now!
It took a while but it's working fine now.
Thanks

Collapse
osinachiuro profile image
Osinachi-Uro

It returns a page that says:

ERROR
Failed to contact the origin