If you intend to use your domain with various services offered by AWS then you need to use Route 53 and point your domain to AWS*.
1. Create Hosted Zone
From AWS console, go to "Route 53" and select "Create hosted zone"
Enter the domain name you want to point to AWS (it can also be a sub-domain), select "Public hosted zone" and click "Create hosted zone"
Once the hosted zone is created, copy the NS (Nameserver) values (you will need them in the next step)
2. Update NS Records in your domain
ℹ️ Basically, in this tutorial, I have assumed that the domain you intend to point to AWS has been registered using a registrar other than Route 53 itself
Login to your domain registrar's account, select the domain and edit the NS records.
Screenshot refers to porkbun since I have registered my domain with them, but the setup is essentially the same for every registrar (GoDaddy, Namecheap, Domain.com, Name.com, .etc)
Click on edit NS (Nameservers)
Enter the NS record copied in the previous step and then click "Submit"
That's it, once the changes have been propagated you will be able to use your domain/sub-domain(s) with the desired AWS services.
ℹ️ Name server changes usually take 24 to 48 hours to fully start working
* ℹ️ You can attach your domain to any AWS service without moving the hosted zone to AWS:
Lightsail/EC2
- Attach a static IP to the instance
- Create a new
A record
and point it to that IP
ECS, EKS, etc. (resources to which you can't attach static IP)
- Attach ELB (elastic load balancer) to the resource
- Create a new
CNAME record
and point it to the URL of the ELB
S3, Cloudfront, Amplify, Elastic Beanstalk, etc.
- Create a new
CNAME record
and point it to the URL of the resource
But AWS route 53 comes with its own set of advantages and route 53 helps to connect the request of the user to infrastructure running in the AWS. If your infrastructure is running on AWS then I would suggest pointing your domain's NS to Route 53's hosted zone.
I tried this with my porkbun domain and it doesn't allow me to create a CNAME with my Cloudfront distribution url. Any suggestions?