Reputation: 361
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
Upvotes: 2
Views: 1259
Reputation: 3493
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.
Upvotes: 3