3

I have created an S3 and I uploaded files on the bucket successfully. Now, I am trying to make it work with CloudFront however it is giving me

IllegalLocationConstraintException

The ap-east-1 location constraint is incompatible for the region specific endpoint this request was sent to.

My S3 url is: http://my-bucket-name.s3.ap-east-1.amazonaws.com/assets/local/css/app.css (this returns me the file)

CloudFront is linked to the S3, and the url: https://id.cloudfront.net/assets/local/css/app.css (this returns me the IllegalLocationConstraintException)


In S3 bucket > Permissions >

"Block Public Access" is Off

"Bucket Policy" is auto-generated:

{ "Version": "2008-10-17", "Id": "PolicyForCloudFrontPrivateContent", "Statement": [ { "Sid": "1", "Effect": "Allow", "Principal": { "AWS": "######" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-bucket-name/*" } ] } 

What am I doing wrong?

4
  • hey senty got any solution for this? Commented Aug 30, 2019 at 9:44
  • @Er.Khatri Even when you auto-select the S3 in CloudFront as related bucket, you still need to put your location manually for making it work. Commented Aug 30, 2019 at 16:39
  • can you add that how we can add that? or even better if you can post that as an answer here itself so that I can upvote that also Commented Aug 31, 2019 at 7:37
  • @Er.Khatri there you go Commented Aug 31, 2019 at 20:38

1 Answer 1

4

My issue was because my CloudFront origin was not in us-east, and when you auto-select your bucket's origin in CloudFront, it doesn't add the location prefix to the url. So make sure you add your s3 location like so:

bucketname.s3.ap-east-1.amazonaws.com

7
  • i am still getting the error, but this time the error is different. It says no access key associated with this account when i try to access the image from s3 using alternate domain of cloudfront Commented Sep 6, 2019 at 7:02
  • actuall error i got "The AWS Access Key Id you provided does not exist in our records." Commented Sep 6, 2019 at 9:48
  • Sounds like it’s a process, right? I’d be happy to know your solution too Commented Sep 9, 2019 at 11:22
  • i needed to change delete the bucket amd re-created it in another region Commented Sep 20, 2019 at 12:30
  • 1
    Thanks for sharing! Commented Sep 30, 2019 at 23:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.