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


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?

  • hey senty got any solution for this?
    – Er. Khatri
    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.
    – senty
    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
    – Er. Khatri
    Commented Aug 31, 2019 at 7:37
  • @Er.Khatri there you go
    – senty
    Commented Aug 31, 2019 at 20:38

1 Answer 1


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:


  • 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
    – Er. Khatri
    Commented Sep 6, 2019 at 7:02
  • actuall error i got "The AWS Access Key Id you provided does not exist in our records."
    – Er. Khatri
    Commented Sep 6, 2019 at 9:48
  • Sounds like it’s a process, right? I’d be happy to know your solution too
    – senty
    Commented Sep 9, 2019 at 11:22
  • i needed to change delete the bucket amd re-created it in another region
    – Er. Khatri
    Commented Sep 20, 2019 at 12:30
  • 1
    Thanks for sharing!
    – closetnoc
    Commented Sep 30, 2019 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.