How To Connect A Domain Name to AWS (EC2) Instance

Route 53 Record Sets | Map a Registered Domain onto an Amazon Machine (ec2) Instance

Observable Value

You have registered a domain like assets4u.co.uk and you want the browser url http://www.assets4u.co.uk to serve the index.html page on the apache2 middleware web server.

Pre-Conditions

  • you have registered a domain name with Amazon’s Route 53.
  • Route 53 sets up (1) hosted zone and two (2) record sets 4u.
  • you have launched an ec2 instance logged in via SSH (port 22)
  • you know the public IP address of your “just-created” instance
  • with sudo apt-get install apache2 you’ve installed a web server
  • you’ve added an inbound TCP rule through Port 80 from 0.0.0.0/0

Let’s say 34.248.41.185 is the public IP address of your newly created instance. Does http://34.248.41.185 in your browswer get you the apache (or nginx) welcome page?

Mission

Our mission is to get http://www.assets4u.co.uk resolving in the browser.

Two (2) Record Sets Are Done

In the AWS console go to the Services tab, then Network and Content Delivery, then Route 53 then Hosted Zones.

Check the “Record Set Count” against the domain. Two (2) hosted zones have been automatically created.

Now click on the domain name link. Can you see two (2) record sets?

  1. A NS record set with 4 Name Servers are done. Tick.
  2. A SOA Start Of Authority set has also been setup. Tick.

Don’t worry if you do not understand the above. Just make sure that they are there.

Add 2 Hosted Zone Record Sets (Console)

Let’s add two (2) record sets to map the newly registered domain to the instance IP address.

Click on Create Record Set. Do not touch the Type that defaults to an IPv4 address. Keep Alias as No. Leave the TTL (Time To Live) as 300 seconds. Keep the routing policy Simple.

  • Leave Name blank. Enter IP Address eg 34.248.41.185 in the value field.
  • Click Create to create the first record set. Then click on Create Record Set again.
  • www. Enter the 4 characters (incl period) in “Name”.
  • Like before you enter the IP Address 34.248.41.185 into the value field.
  • Click Create to create the second record set.

Well done. Now go to your browser. Type in

http://assets4u.co.uk and
http://www.assets4u.co.uk

Both URLs should now work. Well done.

Add 2 Hosted Zone Record Sets (AWS CLI)

Are you a DevOps guru practising continuous delivery? Do you automatically provision infrastructure resources?

If yes and yes, you can create the record sets using the AWS CLI (Command Line Interface). You can do it in Bash, Java, Python, Ruby, C# and even Powershell. Using BASH – here is the command to setup the two record sets.

Advanced – Creating a Url Sub-Domain

If you want to setup an auto-provisioned URL like



http://dev-environment.7064.1137.assets4u.co.uk/

then you need to one more record set in order to append dev-environment.7064.1137 to your base url.

What Next – Configure HTTPS / SSL Web Traffic

Professional websites use HTTPS / SSL (encrypted) traffic for all communications. Google and Bing reward sites carrying HTTPS as the people behind the website are serious about protecting customer information.

Why not configure HTTPS for your site now. You can do it.

Leave a Reply

Your email address will not be published. Required fields are marked *