Intro

I previously hosted my domains with GoDaddy. In their service it was pretty trivial to redirect a URL from one domain to another. I own the domain bradleysearle.com and I redirect it to https://codingpackets.com/. The process to do this is not as simple with AWS so in this post I will show you how to accomplish this using the Route 53 and S3 services.

S3

Firstly you must create an S3 bucket. Browse to:

Enter the bucket name and set the bucket region and press create bucket.

blog/aws-redirect-url-with-route-53-and-s3/create-bucket.png

To modify the bucket to act as a Static web hosting bucket browse to:

Select the option the Redirect requests, enter the URL in the Target bucket or domain field. Protocol, Then press save.

blog/aws-redirect-url-with-route-53-and-s3/web-host-bucket.png

That's it for the S3 component. Now lets move onto the Route 53 component.

Route 53

Note
Your domain must be managed with AWS route 53. I will not cover the process of registering or transferring your domain in this post.

Create a hosted zone for your domain. Browse to:

Enter the Domain Name, keep the type as Public Hosted Zone the press Create.

blog/aws-redirect-url-with-route-53-and-s3/create-hosted-zone.png

Browse to the newly created Hosted Zone

Create an Alias record by pressing the Create Record Set button.

Select the Alias: Yes button and select the previously created S3 <bucket-name>. Then press Create.

blog/aws-redirect-url-with-route-53-and-s3/create-record-set.png

That's it for the Route 53 component.

Note
It may take 15mins or so for DNS to propogate.

Testing

The trusty curl CLI tool can be used to test the redirect is working.

cmd
curl -sD - -o /dev/null bradleysearle.com

# output
HTTP/1.1 301 Moved Permanently
x-amz-id-2: bg3q2exWKIyi4+qzEH+30WwBlIrpxDoZD37k6Q7BMn3+qpBMTamUBYLCw++MY6eLzFEB5ju6cJM=
x-amz-request-id: 5F858D21794D6A70
Date: Tue, 05 May 2020 21:25:00 GMT
Location: https://codingpackets.com//
Content-Length: 0
Server: AmazonS3

You can see from the output we get a HTTP 301 redirect for bradleysearle.com that points to https://codingpackets.com/. SUCCESS!!!!

Outro

In this post I showed you how to setup a URL redirect using the AWS Route 53 and S3 services. Its not as simple as some other service providers but at the same time there is not a lot to it.

# aws