2

Is there any solution to get a public hostname in google cloud like in other cloud platforms? Currently the machine name is: computername.c.googleprojectid.internal

but I want something like in Amazon or in Azure: computername.cloudapp.net

user3296520
  • 361
  • 2
  • 4
  • 12
  • 1
    Ok sorry I found it: computername.c. googleprojectid.googleapis.com – user3296520 Sep 08 '14 at 13:09
  • It looks like *.googleapis.com is a CNAME to googleapis.l.google.com., which is a Google load-balanced name for googleapis.com. I don't think that will match your GCE computer's external IP address. – E. Anderson Sep 08 '14 at 20:07
  • @user3296520 where did you found that? or how can I find it for my instance? – harishr Oct 20 '19 at 18:02

1 Answers1

3

You can use the Google Cloud DNS service to update the DNS record for your host on startup. (You could also use a service like dyn-dns, but I'm assuming that you want to us the Google tools where possible.) It looks like you'd want to use the "create change" API, using a service account associated with your VM. This would look something like:

POST https://www.googleapis.com/dns/v1beta1/projects/*myProject*/managedZones/*myZone.com*/changes

{
  "additions": [
    {
      "name": "computername.myZone.com.",
      "type": "A",
      "ttl": 600,
      "rrdatas": [
        "200.201.202.203"
      ]
    }
  ],
  "deletions": [
  ],
}

Note that 200.201.202.203 needs to be the external IP address of your VM.

E. Anderson
  • 3,405
  • 1
  • 16
  • 19