redirecting a subdomain to google cloud

2.5k views Asked by At

I have domain under which there are multiple subdomains pointing to different websites hosted on azure. I am starting to explore google cloud and want to host a subdomain on google cloud.

Below is how DNS record should look like

A - GO Daddy hosted main website IP address

CNAME - subdomain.example.com - subdomain.cloudapp.net
CNAME - subdomain2.exapmple.com - subdomain2.cloudapp.net

now I want to add a cname for another subdomain to be hosted on google cloud

CNAME - subdomain3.example.com ??.googleapi.com

I have public IP address from GCP, but how do I get subdomain for GCP to be used for CNAME record? As per answers to my another question GCP does not provide public CNAME for VM instances. So what should I provided in CNAME record. (I do not want to move the DNS to google, or to azure for that matter)

2

There are 2 answers

0
robsiemb On BEST ANSWER

Based on your question and the reference to Google not providing names for VM instances, I am assuming that you are trying to create a DNS record for the external address of a VM instance.

If you have a static IP address, you should just configure your DNS provider to use an A record for that IP address, rather than a CNAME.

CNAME records just create aliases for the target names, where A records can point directly to the correct IP.

Note that if the IP on your instance is ephemeral rather than static, then you would need to keep updating the DNS record whenever you restart the instance (and get a new IP), so it would be highly recommended to use a static IP for the instance in this case.

1
ThisIsMyName On

I often use App Engine, for a CNAME, you have to map to ghs.googlehosted.com (https://cloud.google.com/appengine/docs/standard/python/mapping-custom-domains). It seems possible to do the same on Compute Engine through the network service (https://cloud.google.com/dns/docs/quickstart#create_a_cname_record). If you don't really need the CNAME record, you should use the classical A record. It's a bit easier.

Don't hesite to look into documentations, everything is explained.