Friday, May 9, 2014

Amazon S3 Bucket custom DNS name

Amazon's S3 is an incredibly useful service for storing files and blobs of data. The data is stored in Buckets which are accessibly via an Amazon generated url, similar to:

or, for example,

The url does end up being a bit unwieldy though. You may also want to cover the potential future scenario of moving away from S3 and not having to deal with urls littered throughout your code bases.
To deal with this, if you already have a DNS name (e.g. you can map it to your bucket. To achieve this:

1. Create a bucket in S3 with the same name as you would like your DNS name to appear. E.g. I wanted to end up with a new "assets" subdomain, e.g.{somefile}, so I made a bucket called "":

2. If you want the bucket contents to be viewable by the public, modify the S3 bucket so that 'Everyone' has 'Open/Download' access to the contents

2. Next, go to your DNS provider to edit your DNS settings. My domain is held by so I used their 'DomainCentral' portal to edit my DNS

3. Add a CNAME alias to point your new subdomain to the s3 bucket name

4. Wait a while for the DNS system to update itself and if all is well, you should be able to access your bucket resources directly, e.g.: