laurilehmijoki / s3_website

Manage an S3 website: sync, deliver via CloudFront, benefit from advanced S3 website features.
Other
2.24k stars 187 forks source link

Support wildcard CNAMEs in Cloudfront #195

Closed jonnyplatt closed 9 years ago

jonnyplatt commented 9 years ago

Cloudfront allows us to create wildcard subdomains for blog.mywebsite.com, sales.mywebsite.com or whatever. It'd be really useful if we could do this in s3_website, but it seems s3_website validates the CNAME and throws an error that the * wildcard symbol is not an alphanumeric character

laurilehmijoki commented 9 years ago

Please paste the error message here.

jonnyplatt commented 9 years ago

Sorry! Here it is:

Applying the configurations in s3_website.yml on the AWS services ... (): did not find expected alphabetic or numeric character while scanning an alias at line 10 column 11 (Psych::SyntaxError)

And the config:

cloudfront_distribution_config: aliases: quantity: 1 items: CNAME: *.abcd.com

laurilehmijoki commented 9 years ago

Try to add quotes, i.e.: CNAME: "*.abcd.com". Will that work?

I don't know if CNAME supports wildcards.

jonnyplatt commented 9 years ago

Yes, that seems to work - thanks!

I think it's the CNAMEs Amazon will accept that are wildcard, not the cname you set your domain to - eg I could configure blog.mysite.com, support.mysite.com or whatever to xyz93231.cloudfront.net and amazon will now resolve them all.

https://aws.amazon.com/about-aws/whats-new/2013/09/18/amazon-cloudfront-announces-wildcard-cname-support/

laurilehmijoki commented 9 years ago

Thanks for linking to the official AWS doc!

laurilehmijoki commented 9 years ago

@jonnyplatt please feel free to update the CNAME tip at https://github.com/laurilehmijoki/s3_website/blob/master/additional-docs/example-configurations.md if you think your setting could be useful to others as well.