Score:1

DNS resolving from Cloudfunctions in VPC network

in flag

I am deploying a Cloudfunction with VPC network as follows:

gcloud beta functions deploy my-function
      --trigger-http
      --region europe-west1
      --memory 128MB
      --runtime nodejs16
      --entry-point entrypoint
      --allow-unauthenticated
      # needed to access compute instances
      # https://console.cloud.google.com/networking/connectors/list
      --vpc-connector cloud-function-connector
      # vpc connector should be used only to access private network
      --egress-settings private-ranges-only

Now, if my Cloudfunction uses IP address of compute resources, I can easily access them. However when I use their hostnames, the DNS are not resolved which ends up with:

Error: getaddrinfo ENOTFOUND my-compute-resource

What do I need to do to be able to use DNS for my compute instances?

John Hanley avatar
cn flag
Which hostnames - public or private? **my-compute-resource** is a hostname. You must use the Fully Qualified Domain Name (FQDN). https://cloud.google.com/compute/docs/internal-dns#view_instance_dns_name
in flag
`my-compute-resource` is a name of the instance. From other instances I can easily ping directly `ping my-compute-instance`. Thanks to you I found out that I can use `my-compute-instance.c.my-project.internal` - I guess that is the best I can get?
John Hanley avatar
cn flag
I sometimes use /etc/hosts and store hostnames and IP addresses. Then I can use any name I want (short or FQDN).
Ramesh kollisetty avatar
au flag
@ Vojtěch Have you tried as @JohnHanley suggested? If yes, Can you post the procedure which you have followed as an answer.
in flag
Hi, I have just used `my-compute-instance.c.my-project.internal` instead of `my-compute-instance` and thats how it works.
Ramesh kollisetty avatar
au flag
@Vojtěch please post your solution as an answer and accept it so that it would be helpful for other community members for reference.
in flag
@JohnHanley if you post your comment as an answer, I will accept it.
Score:1
cn flag

To access a resource via a host name, you must use the Fully Qualified Domain Name (FQDN). Only using the host portion will fail.

A Compute Engine VM has the following FQDN format:

VM_NAME.ZONE.c.PROJECT_ID.internal

If you only specify the VM_NAME, for which ZONE and PROJECT_ID should the request resolve to? That answer also determines which internal DNS server should be queried for the answer.

To prevent that ambiguity, Google Cloud DNS requires FQDN.

Internal DNS names and Shared VPC

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.