IllegalLocationConstraintException on CloudFront (for S3)
Even when you auto-select the S3 in CloudFront as related bucket, you still need to put your location manually for making it work.
Update:
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
- Go to your CloudFront dashboard and click on the distribution ID
- Go to 'Origins and Origin Groups' tab
- select your origin and click 'edit
- edit 'Origin Domain Name' to match this format
bucketname.s3.regioncode.amazonaws.com
- save and wait for 'deployed' state