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.


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:

  1. Go to your CloudFront dashboard and click on the distribution ID
  2. Go to 'Origins and Origin Groups' tab
  3. select your origin and click 'edit
  4. edit 'Origin Domain Name' to match this format
  5. save and wait for 'deployed' state