How To Connect A Domain Name to AWS (EC2) Instance
Route 53 Record Sets | Map a Registered Domain onto an Amazon Machine (ec2) Instance
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.
- 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
sudo apt-get install apache2you’ve installed a web server
- you’ve added an inbound TCP rule through Port 80 from 0.0.0.0/0
184.108.40.206 is the public IP address of your newly created instance. Does
http://220.127.116.11 in your browswer get you the apache (or nginx) welcome page?
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
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?
NSrecord set with 4 Name Servers are done. Tick.
SOAStart 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
18.104.22.168in 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
22.214.171.124into the value field.
- Click Create to create the second record set.
Well done. Now go to your browser. Type in
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
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.