[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\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)."]]