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
- Launch an EC2 Instance.
- Name your instance: MyDomainServer
- Quick Start: Amazon Linux
- Amazon Machine Image: Amazon Linux 2 AMI (HVM) (Free Tier eligible)
- Architecture: 64-bit (x86)
- Instance type: select t3.micro
- Under Key pair (login): Create new key pair. (If you don't have one)
- Create key pair pop up.
- Key pair name: MyKeyPair
- Key pair type: RSA
- Private key file format: .pem
- Create key pair.
- Save it on your local device.
Network Settings
- Edit.
- Firewall (security groups).
- Create security group.
- Security group name — required: MySecurityGroup.
- Description — required: type in Security Group for My Web Domain
- Inbound Security Group Rules.
- Add Security group rule.
- HTTP.
- Source Type: Anywhere.
- Configure storage: leave as default.
- Advanced details: leave as default.
- Scroll to the bottom.
- 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 &
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
- Open Hosted Zone
- Create Record
- Record Type: A
- Record name: ec2
- Value: Paste IPv4 address of ec2 instance
- Create record
- Status Message: INSYNC
- Paste in Browser: ec2.studentanalyst.co.za (ec2.your-domain.com)
- Message: Hello World
- 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.