1

I have a bucket on Amazon s3 which contains some jpeg images. For SEO purposes I want to serve my images from my subdomain like http://images.example.com

Currenly my bucket name does not looks like a subdomain. It only contains a dash like my-images

In this article, author says: Create a bucket which looks like a subdomain.

So can I alias my subdomain with CNAME record with this bucket name?

Also this solution support author's idea: https://stackoverflow.com/a/18766082/1848929

Must I rename my bucket? Is it possible to rename a bucket?

Community
  • 1
  • 1
hakki
  • 6,181
  • 6
  • 62
  • 106

2 Answers2

2

Your bucket name must match the CNAME (Or Alias) record you point to the bucket.

The bucket name must be the same as the CNAME

http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html

It is not possible to rename a bucket. In the other answer you referenced, I suspect this was a casual use of the word "rename," which actually was intended to mean "create a bucket with a different name," because:

After you create a bucket, you cannot change its name.

http://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html

So, to point a DNS entry from one of your domains directly at a bucket, you will need a bucket with a matching name.

There is one alternative, however, which does not require you to change the name of the bucket, which might be a good idea anyway: you can use the CloudFront CDN in front of your bucket.

If you create a CloudFront distribution, you can tell CloudFront which DNS names you intend to point to it, and then configure CloudFront to serve the requests from a bucket you specify -- and in this case, the name of the bucket no longer matters, because CloudFront handles the hostname-to-bucket mapping automatically.

This further gives you the potential performance enhancement of caching your image assets closer to frequent visitors of your site, and allows you to use SSL with your subdomain as the hostname (using a free SSL cert from Amazon Certificate Manager) which is only possible with CloudFront+S3, not S3 alone.

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
1

You need to create a bucket with the name images.example.com

Then you will need to CNAME it in your DNS.

images.example.com -> images.example.com.s3.amazonaws.com.

Is it possible to rename a bucket?

No, you can't change the name of the bucket once it has been created. The workaround is to create a new bucket and copy the files to it.

MMT
  • 1,931
  • 3
  • 19
  • 35
  • 1
    *"although it's not a must, it just looks beter."* Well, yes, it **is** a must. You can't randomly point a CNAME record to a bucket. The bucket name has to match the fully-qualified hostname. – Michael - sqlbot May 08 '16 at 23:19
  • Thanks @Michael-sqlbot I have corrected the answer. – MMT May 09 '16 at 06:39
  • Thank you for correcting your answer. -1 removed. You may also wish to reverse the notation on the `CNAME` for clarity, since `images.example.com` `->` `images.example.com.s3.amazonaws.com` more accurately reflects what is pointing to what, and s/walk/work/, since I assume you mean "workaround." – Michael - sqlbot May 09 '16 at 12:26