5

I'd like to make a CNAME record for my Amazon S3 domain, to have nicer URLs.

There's not much discussion of this out there on the web, and nothing at all in the Amazon documentation (unless I'm missing it). Is this a reasonable thing to do? Are there any drawbacks?

John Bachir
  • 2,364
  • 7
  • 29
  • 37

2 Answers2

11

AFAIK there is nothing special to it. In your public DNS just create "your-name.your-domain.com" as a CNAME to "your-bucket-name.s3.amazonaws.com" and have the folder name match your domain name.

CNAME record for my Amazon S3 domain, so have nicer URLs

I assume you have your website hosted elsewhere. Inside the HTML there are links to images, videos etc hosted on S3. You'd like these links to look nicer.

Is this a reasonable thing to do?

Well, for some. I don't think too many end users will look into your HTML or notice what their browser is loading -- and if they do, I don't think they care.

Are there any drawbacks?

One more single point of failure (your DNS config), but it's probably insignificant as you already have this same issue for your main website. A (quite) small slowdown for your users, as they have to make one additional DNS lookup now. First one for your CNAME (fx static.yourdomain.com) and then one for S3. That's maybe ~100 ms on average, not much.

A quick note: It seems you're already using S3. If it works well, then that's fine. If your audience is somewhat global, and you have fair traffic, then you could use a Content Delivery Network instead. Amazon's own Cloudfront of course comes to mind, but it's not the fastest CDN around. To get a feel for the speed of various CDNs you can use Cloud Harmony's test tools from a couple of locations. For small files (CSS, JS, images) pay special attention to latency. For video throughput is more important, but that's rarely a problem for a CDN.

  • I have a service that sends users to download files, so the URLs are a bit more visible than they would be if they were just for static assets in a webpage. Good point about the additional point of failure. I'll check out cloud harmony's test tools, thanks. – John Bachir Aug 21 '10 at 15:02
  • For larger file downloads I think S3 is perfect. CDNs are mostly good for a) many small files, such as websites or b) large amounts of users who download the same content, such as video or software downloads. If each of your files is just downloaded a few times, then a CDN won't improve anything over regular S3 alone. –  Aug 21 '10 at 20:25
  • I tried this but it doesn't work. It says there is no such bucket. The other approach below (http://carltonbale.com/how-to-alias-a-domain-name-or-sub-domain-to-amazon-s3) works fine but this time s3 redirects the request to something like static.xyz.com.s3-external-3.amazonaws.com when you type static.xyz.com (a bucket named static.xyz.com must be created on S3). – Zafer May 06 '11 at 12:34
3

This should cover what you are wanting. Post your comments, etc for additional help:

http://carltonbale.com/how-to-alias-a-domain-name-or-sub-domain-to-amazon-s3

drewrockshard
  • 1,763
  • 4
  • 20
  • 27
  • I believe this post you referenced is out of date as the cname should point to our-bucket-name.s3.amazonaws.com and not s3.amazonaws.com as listed in the post – Schmidty Mar 03 '11 at 22:38
  • Ok ... but as you can see, I gave this answer in August of last year... – drewrockshard Mar 04 '11 at 07:14