Route53 in AWS: Full practical implementation
Amazon Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service. To begin, you'll need to create an EC2 instance. During the creation process, you can add a user script that will automatically run and execute. This script will install the Apache web server on your EC2 instance.
Step1: Create an EC2 instance first
We will add a user script, will run and execute while creating the instance
Navigate to Launch EC2 Instance.
Go to Advanced Settings.
In the User Data section, add the following script to install Apache:
#!/bin/bash
sudo apt update -y
# Install Apache web server (httpd)
sudo apt install -y apache2
sudo systemctl enable apache2
# Create a simple HTML file to verify the web server is running
echo "<html><h1>Welcome to Apache Web Server from Virginia<\/h1><\/html>" | sudo tee /var/www/html/index.html > /dev/null
This script will install apache webserver in your EC2
Step 2: Set Up Route 53
- Go to the Route 53 console and click on Get started.
Click on Get started
- Create a hosted zone for your domain. If you purchased the domain through AWS, the hosted zone is set up automatically.
For external domains (e.g., from GoDaddy), create a public hosted zone with your domain name.
- You will see a record with your domain name in the hosted zone.
See: You will get a record with your domain name in the hosted zone, ready now:
You will see two records
- Copy the nameservers from Route 53 and update them in the domain provider's nameserver section.
Copy these Nameserver from your Route53: Add to above Domain provider in Nameserver section.
Successfully added
Your request will come to hosted zone till now, where to route next?
Create a record now:
Add www in subdomain and ip address of your ec2 instance in value: Create record
Check indietrip.in : this routed to ec2 instance we created with help of user data script: A simple webpage apache.
indietrip.in is opening our ec2 apache2 webpage
We used “A” routing policy : domain name → ipv4
USE CASE 2: I want to serve my website globally with low latency
We will create a new ec2 instance in mumbai region
And we will edit the records of route 53
Edit the record for eu-ireland
This serve as Latency based routing policy.
Create a new ec2 instance in mumbai region and setup latency based routing policy for same website
Add a new record based on mumbai region latency routing policy
As you can see, now our latency based routing policy has been setup
Now you will see we are getting redirected to mumbai, we setup the latency based routing policy
Use Case 3: Set Up Health Checks
In the Route 53 console, navigate to the health checks section.
Create a health check for your EC2 instance.
Add the health check to your hosted zone records.
- You can also configure Amazon SNS notifications to alert you if the instance becomes unhealthy.
Add your health check in hosted zone → records
We can also add sns for healthcheck if the instance goes unhealthy
By following these steps, you can effectively set up and manage your DNS with Amazon Route 53, ensuring high availability and low latency for your website.