DEV Community

Cover image for How to Add DNS Records for Your Domain in Route53
Ntombizakhona Mabaso for AWS Community Builders

Posted on • Edited on

How to Add DNS Records for Your Domain in Route53

After configuring your Public Hosted Zone and updating your Name Servers at your third-party registrar, you type your domain name into the browser:

DNS_PROBE_FINISHED_NXDOMAIN

Oh no! Your domain name isn't resolving because it doesn't have an IP address associated with it. Therefore, it's time to obtain an IP address via an EC2 instance and add the necessary DNS records.

Let's Build... In Public.

Launch An EC2 Instance

  1. Launch an EC2 Instance.
  2. Name your instance: MyDomainServer
  3. Quick Start: Amazon Linux
  4. Amazon Machine Image: Amazon Linux 2 AMI (HVM) (Free Tier eligible)
  5. Architecture: 64-bit (x86)
  6. Instance type: select t3.micro
  7. Under Key pair (login): Create new key pair. (If you don't have one)
  8. Create key pair pop up.
  9. Key pair name: MyKeyPair
  10. Key pair type: RSA
  11. Private key file format: .pem
  12. Create key pair.
  13. Save it on your local device.

Network Settings

  1. Edit.
  2. Firewall (security groups).
  3. Create security group.
  4. Security group name — required: MySecurityGroup.
  5. Description — required: type in Security Group for My Web Domain
  6. Inbound Security Group Rules.
  7. Add Security group rule.
  8. HTTP.
  9. Source Type: Anywhere.
  10. Configure storage: leave as default.
  11. Advanced details: leave as default.
  12. Scroll to the bottom.
  13. User data — optional.

Paste this:

#!/bin/bash

# Update and install dependencies
sudo yum update -y
sudo yum install -y python3
sudo pip3 install flask

# Create a directory for the app
mkdir /home/ec2-user/hello-world

# Create the Flask application
cat > /home/ec2-user/hello-world/app.py <<EOF
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return "Hello World"

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80)
EOF

# Run the Flask app
nohup python3 /home/ec2-user/hello-world/app.py &
Enter fullscreen mode Exit fullscreen mode

Number of instances: 1.
Launch instance.

Add DNS Records in Route 53

Once Route 53 is managing your domain, you can set up DNS records to route traffic.

A Record (Address Record):
Maps your domain to an IP address.
studentanalyst.co.za → 88.80.66.177 (IP of an EC2 instance).

CNAME Record (Canonical Name Record):
Maps a subdomain to another domain.
www.studentanalyst.co.za → studentanalyst.co.za

MX Record (Mail Exchange):
Directs emails sent to your domain to your mail server.
example.com → mail.example.com.

TXT Record:
Used for domain verification or to specify additional information, such as SPF or DKIM for email security.

Adding a Record

  1. Open Hosted Zone
  2. Create Record
  3. Record Type: A
  4. Record name: ec2
  5. Value: Paste IPv4 address of ec2 instance
  6. Create record
  7. Status Message: INSYNC
  8. Paste in Browser: ec2.studentanalyst.co.za (ec2.your-domain.com)
  9. Message: Hello World
  10. Congratulations.

Conclusion

Route 53 is your DNS manager, and with it, you can now do much more with your domain while taking full advantage of AWS services, and launch sites that map to your domain.

Top comments (0)