DEV Community

Create a subdomain in Amazon Route53 in 2 minutes

Arswaw on February 26, 2019

In this guide, I will show you to create a subdomain in Amazon Route53. An example of how this is useful could be adding api onto your existing do...
Collapse
 
abhishekagarwal3003 profile image
abhishekagarwal-3003

Hi..
This is my scenario..
I've a domain say "example.com" which is hosted externally i.e., not on Route53, and now I want to create a sub-domain say "test.example.com" in Route53 which would be used to reach the site from my client network(data center) over DirectConnect, and the url would be say "api1.test.example.com" and "api2.test.example.com", both pointing to the same server in the AWS VPC. So may I know how should I proceed with the Route53 configuration? Do I also need to use Route53 resolver endpoint in this case?

Collapse
 
arswaw profile image
Arswaw

Yes. Using a private hosted zone, you should expect to use R53 Resolver.

Collapse
 
abhishekagarwal3003 profile image
abhishekagarwal-3003

Hi Arswaw,

Thanks for the reply. What if I use a public hosted zone?

Thread Thread
 
arswaw profile image
Arswaw

According to the AWS docs:

"You can also use a Route 53 private hosted zone to route traffic within one or more VPCs that you create with the Amazon VPC service."

This implies that you need a private hosted zone to route to VPC.

Check out this forum response from an AWS employee specifying how you can use the public and private hosted zones together.

Does this help?

Thread Thread
 
abhishekagarwal3003 profile image
abhishekagarwal-3003

Hi Arswaw,

Yes, it helps, it's Private Hosted Zone which I need to use in this case. So is it mandatory to use a Route53 resolver in between or I can map api1.test.example.com and api2.test.example.com directly to my server's private ip on the remote DNS server?

Asking this because I tried both i.e., mapping directly to server's ip as well as mapping to resolver inbound endpoint ip, and what I see is that the former works but the latter doesn't. So any idea where am I going wrong?

Thread Thread
 
arswaw profile image
Arswaw

As convenient as that would be, I would use Resolver. It will take additional setup. However, it will take less setup than the alternative which is to build your own DNS servers.

If you successfully accomplish your mission with the tools you have available to you, would you let me know? I could edit the article to discuss what Route53 can do regarding hybrid clouds.

Should you need additional help, I will be checking this website regularly.

Thread Thread
 
abhishekagarwal3003 profile image
abhishekagarwal-3003

Sure, thanks for your help.

Collapse
 
shamabbas profile image
sham

Scenario is like:
I have a domain and also sub-domain and all the records are created within hosted zone (Route53) already. (DevOps guy created)
Now need to create another subdomain without choosing a different server (IP).
I have tried creating record set within the hosted zone using A and the same IP as for the other sub-domain, didn't work. Also tried A and ELB in Alias Target but that didn't work either.

What could be done in such case?

Collapse
 
thebazshah profile image
Muhammad Shahbaz

If you are directing all of your subdomains to same IP address, you'll have to configure your web server to handle your subdomains differently. For example yourdomain.com, sub1.yourdomain.com and sub2.yourdomain.com will be directed to same IP address but yourdomain.com will run code at path /var/www/html, sub1 will run application at path /var/www/sub1, and sub2 will run code at /var/www/sub2.
It's not Route53, it's your web server that needs to be configured. If you're using Nginx, following article can help you.
dev.to/on_stash/configure-nginx-to...

Collapse
 
arswaw profile image
Arswaw

You're saying that you want to create a second subdomain that resolves to the same IP address as the first?

Collapse
 
nasabayat profile image
Naser Bayat

Hi Arswaw,

Thanks for your help.

Collapse
 
brianacox1964 profile image
Brian Anthony Cox • Edited

Hi, thanks for your blog... like so many others I'm also struggling with setting up a www subdomain.

Before we do our main website, I'm practicing with foreskinconsulting.co.uk ... which works nicely on S3 and Route53. The problem is that whether I do, and there seems to be different approaches, I can't get www. foreskinconsulting .co .uk to work... I get getting 404 NoSuchBucket. I've been through and followed your instructions, I hope, to the letter....

Collapse
 
arswaw profile image
Arswaw • Edited

You need to create called yourdomain.co.uk and then have it redirect to yourdomain.com in the static site options. If you need further help on this, I can provide them.

Collapse
 
niyazpoyilan profile image
Niyaz Poyilan

currently the domain "example.com" is hosted on AWS Route 53. Now I want to create a sub-domain "shop.example.com" , but it would have different nameserver (Not AWS). Will it be possible to do so

Collapse
 
arswaw profile image
Arswaw

There shouldn't be any reason why not. I will look at this when I return to my computer and give you a definitive answer.

Collapse
 
niyazpoyilan profile image
Niyaz Poyilan

Thank you. Will be looking forward to hearing from you

Collapse
 
niyazpoyilan profile image
Niyaz Poyilan

Hey, Any update?

Thread Thread
 
arswaw profile image
Arswaw

Hey, apologies for forgetting about this. I will work on this today.

Collapse
 
cankaraman profile image
Can Karaman

Hi,
You can also create sub-domains in the same hosted zone for simple projects:
docs.aws.amazon.com/Route53/latest...

Collapse
 
seaguy profile image
William Laing

Thank you, Arswaw, very helpful!