Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Conectividade com serviços hospedados em um ambiente sem servidor
Esta página descreve como configurar os Integration Connectors para se conectar a serviços hospedados em ambientes sem servidor, como o Cloud Run no Google Cloud.
A imagem a seguir mostra uma configuração de conectividade de rede particular dos Integration Connectors para um serviço hospedado no ambiente do Cloud Run no Google Cloud:
Nesta página, consideramos que você esteja familiarizado com os seguintes conceitos:
Ao criar um anexo de serviço do PSC, considere os seguintes pontos principais:
O anexo de serviço do PSC e o balanceador de carga são criados em sub-redes diferentes
na mesma VPC. E, especificamente, o anexo de serviço é sempre criado em uma sub-rede NAT.
O tráfego do balanceador de carga e da sondagem de verificação de integridade precisa ser enviado para a mesma porta.
Configure as regras de firewall para facilitar o fluxo de tráfego.
Regras de entrada
O tráfego da sub-rede do anexo do serviço PSC precisa chegar ao seu serviço de back-end.
Regras de saída
O tráfego de saída é ativado por padrão em um projeto do Google Cloud, a menos que regras de negação específicas sejam configuradas.
Todos os componentes do Google Cloud, como o anexo do serviço do PSC e o balanceador de carga, precisam estar na mesma região.
Criar um anexo de serviço do PSC
Para estabelecer conectividade privada com os Integration Connectors, seu serviço precisa ser exposto a eles usando um anexo de serviço do PSC. Um anexo de serviço sempre usa um balanceador de carga. Portanto, se o serviço não estiver atrás de um balanceador de carga, será necessário configurar um.
Criar um balanceador de carga. Se você já tiver um balanceador de carga, pule esta etapa.
Nesse comando, LIMIT é o limite de conexão do projeto. O limite de conexão é o número de endpoints do PSC do consumidor que podem se conectar a esse serviço. Para receber o SERVICE_DIRECTORY_PROJECT_ID, siga estas etapas:
É possível criar o anexo de serviço do PSC para que ele aceite solicitações apenas dos projetos do Google Cloud especificados. No entanto, para fazer isso,
você precisa do ID do projeto do diretório de serviços associado ao seu projeto do Google Cloud. Para conferir o ID do projeto do diretório de serviços, use a API List Connections, conforme mostrado no exemplo a seguir.
Em alguns casos, como back-ends com TLS ativado, o destino exige o uso de
nomes de host em vez de IPs particulares para realizar a validação de TLS. Nos casos em que um DNS
particular é usado em vez de um endereço IP para o destino do host, além de criar um anexo
de endpoint como um endereço IP, também é necessário configurar zonas gerenciadas. Para instruções sobre como criar um anexo de endpoint como um nome de host, consulte Criar um anexo de endpoint como um nome de host.
Depois, quando você configurar a conexão para usar o anexo de endpoint, poderá selecionar esse anexo.
Configurar uma conexão para usar o anexo do endpoint
Agora que você criou um anexo de endpoint, use-o na sua conexão. Ao criar ou atualizar uma conexão, na seção "Destinos", selecione Anexo de endpoint como Tipo de destino e selecione o anexo de endpoint criado na lista Anexo de endpoint.
Se você criou uma zona gerenciada, selecione Endereço do host como Tipo de destino e use o registro A criado ao criar a zona gerenciada.
Dicas de solução de problemas
Siga as diretrizes listadas nesta seção para evitar problemas comuns:
Para verificar se o anexo do endpoint está configurado corretamente e a conexão PSC foi estabelecida, verifique o status da conexão. Para mais informações, consulte Verificar a conexão de anexo do endpoint.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 UTC."],[[["\u003cp\u003eIntegration Connectors can be configured to connect to services in serverless environments like Cloud Run through private network connectivity.\u003c/p\u003e\n"],["\u003cp\u003eEstablishing private connectivity requires exposing the service to Integration Connectors using a Private Service Connect (PSC) service attachment, which uses a load balancer.\u003c/p\u003e\n"],["\u003cp\u003eThe PSC service attachment and load balancer must be in the same region but in different subnets within the same VPC, with the service attachment always in a NAT subnet.\u003c/p\u003e\n"],["\u003cp\u003eFirewall rules need configuration to allow ingress traffic from the PSC service attachment's subnet to the backend service, and egress traffic is generally enabled by default.\u003c/p\u003e\n"],["\u003cp\u003eEndpoint attachments, either as IP addresses or hostnames, can be created and used to connect, and in the case of hostnames, managed zones are also necessary.\u003c/p\u003e\n"]]],[],null,["# Connectivity to services hosted in serverless environment\n=========================================================\n\nThis page describes how you can configure Integration Connectors to connect to services hosted in serverless environments such as Cloud Run in Google Cloud.\n\nThe following image shows a private network connectivity setup from Integration Connectors to a service hosted in the Cloud Run environment in Google Cloud:\n\n\nThis page assumes that you are familiar with the following concepts:\n\n- [Endpoint attachments](/integration-connectors/docs/network-connectivity-private#endpoint-attachments)\n- [Managed zones](/dns/docs/zones)\n- [Private Service Connect (PSC)](/vpc/docs/private-service-connect)\n- [Google Cloud load balancer](/load-balancing)\n\n### Considerations\n\nWhen you create a PSC service attachment, consider the following key points:\n\n- The PSC service attachment and the load balancer are created in different subnets within the same VPC. And specifically, the service attachment is always created in a NAT subnet.\n- Traffic from load balancer and health check probe must be sent to the same port.\n- Configure the firewall rules to facilitate the traffic flow. **Ingress rules**\n\n Traffic from the PSC service attachment's subnet must reach your backend service.\n\n\n **Egress rules**\n\n Egress traffic is enabled by default in a Google Cloud project, unless specific\n deny rules are configured.\n- All your Google Cloud components such as the PSC service attachment and the load balancer must be in the same region.\n\n### Create a PSC service attachment\n\nIn order to establish private connectivity from Integration Connectors, your service must be exposed to Integration Connectors using a PSC service attachment. A service attachment always uses a load balancer. Therefore, if your service isn't behind a load balancer, a load balancer needs to be configured.\n| The steps described in this section assume that you already have your backend service installed and configured.\n\n1. Create a load balancer. If you already have a load balancer, skip this step. Create an application load balancer using serverless NEG as the backend by following the instructions at [Set up a regional internal Application Load Balancer with Cloud Run](/load-balancing/docs/l7-internal/setting-up-l7-internal-serverless).\n\n2. Create the service attachment\n 1. Create a subnet for PSC NAT. The following command creates a subnet with the name `psc-nat-subnet1` and the purpose is `PRIVATE_SERVICE_CONNECT`. \n\n ```scdoc\n gcloud compute networks subnets create psc-nat-subnet1 \\\n --network=VPC_NETWORK --range=SUBNET_RANGE_1 \\\n --purpose=PRIVATE_SERVICE_CONNECT\n ```\n 2. Create a firewall rule to allow traffic from the PSC NAT to the load balancer. \n\n ```component-pascal\n gcloud compute network-firewall-policies rules create PRIORITY --firewall-policy FIREWALL_POLICY_NAME_SA \\\n --direction=INGRESS --network=VPC_NETWORK \\\n --action=allow --allow=tcp:BACKEND_SERVER_PORT --src-ip-ranges=SUBNET_RANGE_1\n ```\n 3. Create service attachment with [explicit approval](/vpc/docs/configure-private-service-connect-producer#publish-service-explicit). \n\n ```scdoc\n gcloud compute service-attachments create SERVICE_ATTACHMENT_NAME --producer-forwarding-rule=FORWARDING_RULE_NAME --connection-preference=ACCEPT_MANUAL --consumer-accept-list=SERVICE_DIRECTORY_PROJECT_ID=LIMIT --nat-subnets=psc-nat-subnet1\n ```\n\n In this command, \u003cvar translate=\"no\"\u003eLIMIT\u003c/var\u003e is the connection limit for the project. The connection limit is the number of consumer\n PSC endpoints that can connect to this service. To get the \u003cvar translate=\"no\"\u003eSERVICE_DIRECTORY_PROJECT_ID\u003c/var\u003e, do the following step:\n - You can create the PSC service attachment such that it accepts requests only from the specified Google Cloud projects. However, to do this,\n you need the project ID of the service directory associated with your Google Cloud project. To get the project ID of the service directory, you can use\n the [List Connections API](/integration-connectors/docs/reference/rest/v1/projects.locations.connections/list) as shown in the following\n example.\n\n | **Note:** Before getting the project ID, ensure that at least one connection is present in your project.\n\n ### Syntax\n\n ```json\n curl -X GET \\\n -H \"authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://connectors.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003eCONNECTORS_PROJECT_ID\u003c/var\u003e/locations/-/connections\"\n ```\n\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCONNECTORS_PROJECT_ID\u003c/var\u003e: The ID of your Google Cloud project where you created your connection.\n\n ### Example\n\n This example gets the project ID of the service directory for the `connectors-test` Google Cloud project. \n\n ```json\n curl -X GET \\\n -H \"authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://connectors.googleapis.com/v1/projects/connectors-test/locations/-/connections\"\n ```\n\n Running this command on the terminal displays an output similar to the following: \n\n ```json\n .....\n {\n \"connections\": [\n {\n \"name\": \"projects/connectors-test/locations/asia-northeast1/connections/big-query-iam-invalid-sa\",\n \"createTime\": \"2022-10-07T09:02:31.905048520Z\",\n \"updateTime\": \"2022-10-07T09:22:39.993778690Z\",\n \"connectorVersion\": \"projects/connectors-test/locations/global/providers/gcp/connectors/bigquery/versions/1\",\n \"status\": {\n \"state\": \"ACTIVE\"\n },\n \"configVariables\": [\n {\n \"key\": \"project_id\",\n \"stringValue\": \"connectors-test\"\n },\n {\n \"key\": \"dataset_id\",\n \"stringValue\": \"testDataset\"\n }\n ],\n \"authConfig\": {},\n \"serviceAccount\": \"564332356444-compute@developer.gserviceaccount.com\",\n \"serviceDirectory\": \"projects/abcdefghijk-tp/locations/asia-northeast1/namespaces/connectors/services/runtime\",\n \"nodeConfig\": {\n \"minNodeCount\": 2,\n \"maxNodeCount\": 50\n }\n },\n ....\n ```\n\n In the sample output, for the `connectors-test` Google Cloud project, the project ID\n of the service directory is `abcdefghijk-tp`.\n\n### Create an endpoint attachment to consume the PSC service attachment\n\n**Endpoint attachment as an IP address**\n\nFor instructions on how to create an endpoint attachment as an IP address,\nsee [Create an endpoint attachment as an IP address](/integration-connectors/docs/create-endpoint-attachment#create-ep-ipaddr).\n**Endpoint attachment as a hostname**\n\nIn certain cases such as TLS enabled backends, the destination requires you to use\nhostnames instead of private IPs to perform TLS validation. In those cases where a private\nDNS is used instead of an IP address for the host destination, in addition to creating an endpoint\nattachment as an IP address, you must also configure managed zones. For instructions on how to\ncreate an endpoint attachment as a hostname,\nsee [Create an endpoint attachment as a hostname](/integration-connectors/docs/create-endpoint-attachment#create-ep-hostname).\n\nLater, when you configure your connection to use the endpoint attachment, you can select this endpoint attachment.\n\n### Configure a connection to use the endpoint attachment\n\nNow that you have created an endpoint attachment, use the endpoint attachment in your connection. When you create a new connection or update an existing connection, in the Destinations section, select **Endpoint attachment** as the **Destination Type** and select the endpoint attachment that you created from the **Endpoint Attachment** list.\n\nIf you created a managed zone, select **Host Address** as the **Destination Type** and use the A-record that you created while creating the managed zone.\n\nTroubleshooting tips\n--------------------\n\nFollow the guidelines listed in this section to avoid common issues:\n\n- To verify that the endpoint attachment is set up correctly and the PSC connection is established, check the connection status. For more information, see [Verify the endpoint attachment connection](/integration-connectors/docs/create-endpoint-attachment#verify-ep-connection).\n- For information about troubleshooting Load Balancer issues, see [Troubleshoot issues with internal Application Load Balancers](/load-balancing/docs/l7-internal/troubleshooting-l7-ilb).\n- [Google Cloud Connectivity test](/network-intelligence-center/docs/connectivity-tests/concepts/overview) can be used to identify any gaps in your network configuration. For more information, see [Create and run Connectivity Tests](/network-intelligence-center/docs/connectivity-tests/how-to/running-connectivity-tests)."]]