5
votes

I have 2 distinct instances on Google Compute Engine.

On the first (lets name it instance1) I have hosted a website (with domain name instance1domain.com linked to it and static IP) and everything is working great.

On the second instance I have a web app that I want to be a subdomain of the site on the first instance (like app.instance1domain.com).

Both my instances are on the same zone with internal IP's from the same subnetwork (in Google Compute Engine).

How ca I map the second instance in Google Cloud DNS in such way that it becomes a subdomain for the site hosted on the first instance ?

1

1 Answers

4
votes

Just create the A record for the second instance with the name app.instance1domain.com and use the IP address of the second GCE instance.

While some extra DNS records are needed if you want to make a second DNS managed zone into a delegated subdomain of the first, you don't need to do that to create a subdomain entry in the same DNS managed zone.

So a single managed zone can have entries for all of the following:

  1. example.com
  2. xyz.example.com
  3. abc.xyz.example.com
  4. abc.def.example.com

In the fourth case, you don't need to create an entry for def.example.com in order to have abc.def.example.com; creating the subdomain abc.def.example.com implicitly creates def.example.com as what is called an “empty non-terminal.”

Note that you cannot create a domain name that is not a subdomain of the zone's domain, so for example, it is not possible to create another-example.com in this zone; you must place it in its own zone.