Sunday, December 18, 2016

Amazon S3 as Image Hosting Service

Create and Configure S3 Bucket

1. Login to AWS Console and create a bucket. In my case
2.  Add the bucket policy to provide read access to everyone:

      "Principal": "*",

3. Upload the image to the S3 bucket. You can also access the image using SSL like this:

This is the image for my upcoming book TDD in Ruby to be released by Apress in 2017. The SSL is important because when your site uses SSL and some of the links are not https, the browser will show SSL errors in the SSL padlock.

Tip: Use to validate bucket policy and fix issues before configuring the bucket.

Use Amazon CloudFront CDN to Speed Up Image Access

Go to Cloudfront and click Create Distribution, provide the bucket name and accept the default values for other form fields. It will take some time for the changes to take effect.

Once the changes are complete, you can access the images using Cloudfront URL like this:

Using your Own Subdomain to Access Assets

You can create CNAME using the UI provided by your host to map the URL: to

I host my Rails app on Linode. I used the dashboard of Linode to map to the URL by creating a CNAME. Now, we can access the same image without like this:

No comments:

Post a Comment