Search code examples
amazon-ec2dnssubdomain

How to get example.com or sub1.example.com to point to my EC2 vm?


I have example.com registered at GoDaddy (and hosted elsewhere). I created a subdomain at sub1.example.com.

I have a virtual linux machine running great on EC2 accessible as ec2-xx-xx-xx-xx.compute-1.amazonaws.com

Question: How do I get sub1.example.com to point to my EC2 virtual machine?


Solution

  • There are two way you can setup this:

    1. If you have EIP configured to your EC2 instance then point your subdomain's A record to this EIP.
    2. Instead of creating a subdomain create a CNAME record with name as subdomain and value as your EC2 public DNS which is ec2-xx-xx-xx-xx.compute-1.amazonaws.com.