Map a sub-domain to an Amazon S3 bucket

publish on

How to map a sub-domain to an Amazon S3 bucket in order to hold your website static data.

Amazon S3 is a cheap way to hold your website static data. You can create a bucket in order to put your resources in it. A bucket is like a container where you can put items such as files and folders. You can then access an item using the following URL https://s3.amazonaws.com/bucket_name/item_name (you need to make the item public first).

This article will show you how to map a sub-domain to an Amazon S3 bucket.

First login to your Amazon Console https://console.aws.amazon.com/.

Go to Amazon S3 section:


Create a new bucket, and name it exactly like your sub domain. In this case I choose static.inoneo.com:


Then upload a resource:


By default the resource is private (only accessible by you). You need to make it public to make it visible by everyone:


The final step is to map your sub-domain with the bucket. To do so go to your registar website and add a new CNAME record:


  1. Type: CNAME
  2. Name: static
  3. Value: s3.amazonaws.com

That's it, you can now try accessing your previously uploaded resource using your sub-domain.

Now, in your website, simply link the resource using your sub-domain directly in the HTML, for example to display an image stored in S3:

<img src="http://static.inoneo.com/aws/static_resources/static_dns.jpg"></img>

comments powered by Disqus