I would like to share my experience in configuring DNS records under your already existing DNS (outside of AWS) for a sub-domain and routing traffic to your EC2 instance for Elastic Beanstalk application using Route 53 of Amazone, phh :P
So you will need:
- EC2 up and running
- Elastic Beanstalk if you use it
- Route 53 (seems paid feature)
- Access to your current DNS records usually your hosting provided or DNS hosting service provide you with access to it
First thing you need is to allocate Elastic IP Address to your EC2 instance (something like Static IP address)
Go to Network & Security > Elastic IPs
Click the Allocate Elastic Ip address and assign it to your EC2 instance.
Now we need to configure Route 53 - go to Route 53 > Hosted Zones and create new zone and name it
as your sub-domain like sub.maindomain.com
Go inside of the zone and create a new record, select Type A - IPv4 address, set Alias to Yes and set your Alias Target to your ElastikBeanstalk instance name and click the Save Record Set button.
Now you need to goe to your hosting or DNS provider and add all NS records that you see under the Route 53 NS type (created by default by AWS).
In my case it was XXXHosting provider that hosted servers and DNS. On the Control Panel I found DNS management
and added a new DNS records for sub.maindomain.com with Type NS and pointing to the NS servers.
Give it some time from 30 minutes to a few hours to propagate through the world and now your subdomain will direct all traffic to your AWS instance.