How to configure Route 53 to Route a Domain to an EC2 Instance on AWS

Find out how to register your domain with ease and configure it to connect using Amazon Route 53 and Amazon EC2

· 4 min read
Myles Mburu

Myles Mburu

Software Developer | AWS CCP

topics

This tutorial will guide you through the process of configuring AWS Route 53 to route a domain to an Amazon EC2 instance. By the end of this guide, you will know how to link your custom domain with a web server running on an EC2 instance using AWS Route 53, which acts as a highly available and scalable Domain Name System (DNS) web service.

Prerequisites

  • An AWS account
  • A registered domain name ( Either from Amazon Route 53 or an external domain registrar like Namecheap or GoDaddy )
  • An EC2 instance up and running on your AWS account

Step 1: Set Up Your EC2 Instance

Before you can route a domain to your EC2 instance, ensure your EC2 instance is configured properly.

  1. Launch an EC2 instance: Choose an Amazon Machine Image (AMI), instance type, and configure instance details as required for your application.
  2. Configure Security Group: Make sure your security group rules allow inbound traffic on the ports you require (usually port 80 for HTTP and 443 for HTTPS).
Image

Step 2: Create a Hosted Zone in Route 53

  1. Navigate to Route 53: Log in to the AWS Management Console, go to Services and select Route 53.
  2. Create Hosted Zone: Click on "Hosted zones" and then "Create hosted zone". Enter your domain name and select the type as "Public Hosted Zone". Click "Create".
Image

Step 3: Update Name Servers

  1. Record Name Servers: Once the hosted zone is created, Route 53 will assign a set of DNS servers to your domain. Note down these DNS server addresses (the ones highlighted in the image).
  2. Update at Domain Registrar: Go to your domain registrar's website and replace the existing name servers with the ones provided by AWS Route 53. This step will vary depending on your registrar.
    In my case, I used NameCheap to purchase my domain. So in the domain management tab, under NAMESERVERS, you coose 'Custom DNS' and paste each of the addresses assigned by Route 53. When done, click on the green check mark to save your configuration changes.
ImageImage

Step 4: Create Record Sets in Route 53

  1. Navigate to Your Hosted Zone: In Route 53, click on the name of your hosted zone corresponding to your domain.
  2. Create Record Set:
    • Click "Create Record Set".
    • Leave the name field blank for the apex domain or provide a subdomain.
    • Select type "A – IPv4 address".
    • Go back to your EC2 instance and copy the Public IPv4 address
    • Paste the EC2 IPv4 address in the value section to set it as the target.
    • Click "Create".
ImageImage

Step 5: Verify the Configuration

  1. Test Your Domain: Open a web browser and type your domain into the address bar. It should route you to your EC2 instance. If it does not, ensure that all settings are correct and that DNS changes have propagated, which can take up to 48 hours.

Conclusion

You've now successfully configured AWS Route 53 to route a domain to your EC2 instance. This setup not only helps in simplifying domain management but also leverages AWS’s scalability and high availability for your DNS needs.

Additional Tips

  • DNS Propagation: Be patient after changing DNS settings, as it may take some time for changes to propagate.
  • Security: Regularly review your security group settings to ensure that your EC2 instance remains secure.
  • Monitoring: Consider using AWS CloudWatch to monitor your EC2 instance and receive alerts on specific metrics or events.

share