CloudFront can’t use S3 Website origin, only REST origin Cloudformation

Question:

I’m trying to automate spinning up a CloudFront distribution with S3 origin. I’d like to set the origin to the S3 website URL, e.g. mysite.com.s3-website-us-east-1.amazonaws.com. So, I thought my Cloudformation template should look like this:

However that yields the following error:

The parameter Origin DomainName does not refer to a valid S3 bucket.

Which is true, so I can specify the S3 bucket. But I want my origin to be the website endpoint. My non-automated workaround is to deploy with the S3 REST endpoint and update the origin in the UI after.

According to the docs:

The DNS name of the Amazon Simple Storage Service (S3) bucket or the HTTP server from which you want CloudFront to get objects for this origin.

I can’t find anything about a website endpoint origin. http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-origin.html#cfn-cloudfront-origin-originpath

Answer:

I don’t think you’ve included quite all the relevant parts of your configuration.

The issue here is that an origin that is an S3 website hosting endpoint is not an S3 origin — it’s a custom origin.

Anything other than the REST endpoint of a bucket is always a custom origin.

Leave a Reply