How to Switch Your Website to Amazon S3 and CloudFront For Static Items
I was looking to increase my experience working with large scalable websites, so I decided to switch all of my static items such as images over to Amazon S3 and CloudFront. S3 is Amazon’s storage service and CloudFront is their content delivery service. By doing this, I get to take advantage of the same infrastructure Amazon uses to run their websites.
From Amazon’s website:
“Amazon CloudFront delivers your content using a global network of edge locations. Requests for your objects are automatically routed to the nearest edge location, so content is delivered with the best possible performance. Amazon CloudFront works seamlessly with Amazon Simple Storage Service (Amazon S3) which durably stores the original, definitive versions of your files.”
This means that I get to upload my website’s images to Amazon’s S3. Then, when a user accesses this website, Amazon CloudFront delivers these images to the nearest edge location of that user. CloudFront stores these images in the edge’s cache until it expires.
The first thing you need to do is sign up. You can sign up for these services at the two links I provided above. The services are extremely cheap. This is the link for the S3 pricing and this is the link for the CloudFront pricing. After you have signed up, you need a way to interface with Amazon’s S3 service. I use Firefox, and there is a great add-on called S3Fox. You can download the add-on from Mozilla here. There are other programs you can use to interface with S3 and CloudFront. However, this how-to will focus on S3Fox. You can find similar tools from Amazon’s developer page here. Whatever tool you decide to use, this how-to should still be relevant. Once S3Fox is installed and the browser has been restarted, go to Tools » S3 Organizer in Firefox.







aaronsofaly.com (the ‘bucket’) » images » theme
aaronsofaly.com (the ‘bucket’) » images » content
Any images that are specific to my theme are in the ‘theme’ directory. The images for the individual posts go inside the ‘content’ folder with another directory named after the title of the post. Therefore, the URLs for the images in this post are:
http://s3.aaronsofaly.com/images/content/How_To_Switch_Your_Website_To_Amazon_S3_and_CloudFront
_For_Static_Items/.
(The ‘s3’ sub domain will be explained shortly. This URL gives an error because it points to the images folder and not a specific image).
The folder structure is in place and we can now upload our items to the corresponding folders. Just click ‘Browse’ on the left hand column of the application and navigate to the folder of the item.





sub-domain.your-domain-name.your-top-level-domain
For example, my ‘CNAME’ is:
s3.aaronsofaly.com


s3 IN CNAME your-cloudfront-domain-name.cloudfront.net
This CNAME alias allows me to use this URL:
This CNAME URL is much cleaner and hides the fact that the images are being delivered by Amazon’s CloudFront. (My ‘s3’ sub domain doesn’t exactly hide the fact that it is delivered by Amazon’s web services because I named it ‘s3’. However, you could use ‘images’, ‘static’, or something other than ‘s3’).
And that’s it! Have a question or comment? Go ahead and leave your feedback in the comments below.
Aaron