
다음과 같이 VPC 네트워크를 사용하여 Cloudfunction을 배포합니다.
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
이제 내 Cloudfunction이 컴퓨팅 리소스의 IP 주소를 사용하면 쉽게 액세스할 수 있습니다. 그러나 호스트 이름을 사용하면 DNS가 확인되지 않아 다음과 같이 끝납니다.
Error: getaddrinfo ENOTFOUND my-compute-resource
내 컴퓨팅 인스턴스에 DNS를 사용하려면 어떻게 해야 합니까?
답변1
호스트 이름을 통해 리소스에 액세스하려면 FQDN(정규화된 도메인 이름)을 사용해야 합니다. 호스트 부분만 사용하면 실패합니다.
Compute Engine VM의 FQDN 형식은 다음과 같습니다.
VM_NAME.ZONE.c.PROJECT_ID.internal
VM_NAME만 지정하는 경우 요청은 어느 ZONE 및 PROJECT_ID로 해결되어야 합니까? 또한 해당 답변에 따라 답변을 쿼리해야 하는 내부 DNS 서버가 결정됩니다.
이러한 모호성을 방지하기 위해 Google Cloud DNS에는 FQDN이 필요합니다.