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?