Simple HTTP Redirects Using AWS Route 53 and S3

Let’s just say that you want to create a redirect for a root domain while using Route 53 on Amazon Web Services.  Many of the popular domain registration and web hosting providers (e.g. GoDaddy, Domain.com, etc.) have baked in settings to redirect to another URL.

In Route 53, there is no native way to do this, but luckily it’s a couple of simple steps away and you also get to learn a little about web site hosting on AWS S3 (Simple Storage Service) at the same time.

My example is for http://virtualdesignmaster.com which has been redirected to http://virtualdesignmaster.io as you can see by clicking the link.  Now, let’s learn how to do that easily with AWS Route 53 DNS service and S3.

Our assumption is that you’ve registered the domain with Route 53 or are at least hosting the DNS zone and have set the SOA (Start of Authority) record and NS (Name Server) records to AWS DNS settings.

Setting up Your S3 Buckets

The reason that I say buckets as a plural, is that we will want to have a working DNS for both the root domain virtualdesignmaster.com and also the www.virtualdesignmaster.com which is normally a CNAME entry to point to the root domain.

Open up your AWS S3 and click the Create Bucket button.  Name your S3 bucket the same as your domain name.  In my case for the example is virtualdesignmaster.com.  I’ve chose to put it in the US Standard region because it’s the closest to the majority of my traffic for the site:

01-create-bucket-base

 

After you click the create button, you need to click the Properties button on the upper right side of the page.  Expand the section which says Static Website Hosting, select the Redirect all requests to another host name radio button, and type the URL that you want to redirect to.  In my case it is www.virtualdesignmaster.io:

02-bucket-redirect-base

Save the changes and repeat the process, but this time you will name the S3 bucket as the www name for your domain.  My example uses www.virtualdesignmaster.com:

03-create-bucket-www

Open the Properties section, expand the section which says Static Website Hosting, select the Redirect all requests to another host name radio button, and type the URL that you want to redirect to:

04-bucket-redirect-www

That is your S3 configuration.  Next up is the DNS settings.

Route 53 Configuration for S3 Targets

Open up your Route 53 configuration in the AWS console.  Select the Hosted Zones area, choose the radio button for the zone we are working on and click Go to Record Sets:

route53-vdm

Click Create Record Set.  Leave the Name section empty, choose A – IPv4 address as the Type:

05-create-a-record-base

Change the Alias from the default of No to Yes:

06-alias

Click in the Alias Target field which brings up a droplist.  It may take up to 20 or more seconds to populate the list.  Under the S3 website endpoints you will see the one you’ve created.  Select that and click the Create button at the bottom:

06-route53-base

Repeat the process of adding a new record.  This time put www in the Name section.  Keep A-IPv4 address as the Type, and click the Alias Target section to select the S3 website endpoint which matches the A record name:

07-route53-www

DNS is a rather magical system, but it will take up to 15 minutes or more update.  Once some time has passed, you can confirm te redirection is in place by trying the URL in a browser.  It should redirect you to the web site that you’ve assigned in your S3 configuration.

You can confirm from the command line using cURL as well.  Type curl --head yourdomain.com which will show you the output below, and then you can also type curl yourdomain.com which will show you the redirect in the output:

08-curl-redirect

Note that this is different than a 301 or 302 redirect.  The method used by the S3 redirection is a META tag instead.  I’m also assuming that you’re aware that there is a cost for the S3 usage.

Costs of Using S3 for Web Site Hosting and Redirection

As listed on the S3 and storage pricing site, the S3 usage qualifies for a Free Tier to AWS users up to the first 20,000 HTTP GET requests per month for the first year of usage.

aws-s3-free-tier

After your Free Tier usage expires, you are charged 0.004$ per 10,000 HTTP GET requests per month in the US East region.  Pricing across regions can be different, so make sure to take that into account when you choose the location of your S3 buckets:

aws-s3-pricing-GET

Hopefully this helps, plus it’s also handy to know as part of your study towards the AWS Solutions Architect Associate exam.




Triple F – Five Friday Favorites: good reads for the week!

There are always a lot of great blogs, tweets, posts, and more happening each and every day. This week I wanted to share out a few tidbits that I have favorited during the week that I recommend for you to take a look at.

1. NSX Compendium by Cisco Inferno (Anthony Burke)

Knowledge is key, and understanding the general workings of VMware NSX is a requirement in my opinion if you are working in virtualization and networking.

http://blog.ciscoinferno.net/nsx-compendium

2. VMware vExpert list for 2014

A phenomenal group of people have been highlighted for their contribution to the VMware community, and I am humbled and proud to be a part of the list of VMware vExperts for 2014! Take a look at the list and be sure to take a look at the great content that all of these folks are putting out.

http://blogs.vmware.com/vmtn/2014/04/vexpert-2014-announcement.html

3. Public cloud instance pricing war

Adrian Cockroft put together a great article which talks about the pricing war that is happening in the public cloud space. With the recent drop in pricing by Google for their public cloud offering, there was an immediate response by Amazon (AWS) and Microsoft (Azure) to put a shot across the each other’s bow as a reminder that the battle for cloud customers is heating up in a good way! The race to zero seems to be on 🙂

http://perfcap.blogspot.ca/2014/04/public-cloud-instance-pricing-wars.html 

4. Cisco introduces OpFlex

Do you like open technologies and networking? I sure do! Cisco debuted their freshly minted RFC for OfFlex this week at Cisco Live. The push to bring ACI to the fore as a leading, open architecture is a great move by the networking giant, and I look forward to seeing this ecosystem strengthen.

http://www.cisco.com/c/en/us/solutions/collateral/data-center-virtualization/application-centric-infrastructure/white-paper-c11-731302.html

5. CloudCareer by Cloud Academy

Cloud Academy is a great site that provides a way to increase your knowledge of cloud platforms and technologies. We just saw the release of the CloudCareer path which will help to give you the fundamentals you need to work towards your AWS certification.

https://cloudacademy.com/cloudcareer/aws-solutions-architect/

BONUS: Microsoft approved image for Vagrant! 

This was an interesting release that happened yesterday from Microsoft. The first legally sanctioned demo images for Windows Server 2012 R2 which are provided in Box format to allow for deployment using the wildly popular Vagrant platform. The image is 8.3 GB, so get your download on now and I look forward to seeing lots of cool stuff coming for this. NOTE: This is a relatively beta release but it is a clear sign that Microsoft is taking note of the power of this type of deployment platform so bravo Microsoft!

http://vagrantbox.msopentech.com/