Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

Connecting to a VPC network

This page shows how to useServerless VPC Accessto connect your App Engine standard environment app directly to yourVPC network, allowing access to Compute Engine VM instances,Memorystore instances, and any other resources with an internalIP address.

Note: Serverless VPC Access connectors incur a monthly charge.For more information, see Serverless VPC Accesspricing.

Before you begin

Create a Serverless VPC Access connector

To send requests to your VPC network and receive thecorresponding responses without using the public internet, you can use aServerless VPC Access connector.

If your connector is located in the same project as its VPCnetwork, you can either create a connector using an existing subnet or createa connector and a new subnet.

If your connector is located in a service project and uses a Shared VPCnetwork, the connector and its associated VPC network are indifferent projects. When a connector and its VPC network are indifferent projects, a Shared VPC network administrator must create theconnector's subnet in the Shared VPC networkbefore you can create theconnector,and you must create the connector using an existing subnet.

To learn more about subnet requirements, seeconnector subnetrequirements.

To learn about connector throughput, including machine type and scaling, seeThroughput and scaling.

You can create a connector by using the Google Cloud console, Google Cloud CLI, orTerraform.

Console

  1. Go to the Serverless VPC Access overview page.

    Go to Serverless VPC Access

  2. ClickCreate connector.

  3. In theName field, enter a name for your connector, matchingCompute Enginenamingconventions, withthe additional requirements that the name must be less than 21characters long, and that hyphens (-) count as two characters.

  4. In theRegion field, select a region for your connector.This must match the region of your serverless service.

    If your service or job is in the regionus-central oreurope-west,useus-central1 oreurope-west1.

  5. In theNetwork field, select the VPC networkto attach your connector to.

  6. In theSubnet field, select one of the following options:

    • Create a connector using an existing subnet: Select the existingsubnet in theSubnet field.

    • Create a connector and a new subnet: SelectCustom IP range intheSubnet field. Then, enter the first address in an unused/28CIDR (for example10.8.0.0/28) to use as the primary IPv4 addressrange of a new subnet that Google Cloud creates in the connector'sVPC network. Ensure that the IP range does not conflictwith any existing routes in the connector's VPC network.The name of the new subnet begins with the "aet-" prefix.

  7. (Optional) To set scaling options for additional control overthe connector, clickShow Scaling Settings to display the scalingform.

    1. Set the minimum and maximum number of instances for your connector,or use the defaults, which are 2 (min) and 10 (max). Theconnector scales up to the maximum specified if traffic usage requiresit, butthe connector does not scale back down when trafficdecreases. You must use values between2 and10.
    2. In theInstance Type menu, choose the machine type to beused for the connector, or use the defaulte2-micro. Notice the costsidebar on the right when you choose the instance type, which displaysbandwidth and cost estimations.
  8. ClickCreate.

  9. A green check mark will appear next to the connector's name when it isready to use.

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. Updategcloud components to the latest version:

    gcloudcomponentsupdate
  3. Ensure that the Serverless VPC Access API is enabled foryour project:

    gcloudservicesenablevpcaccess.googleapis.com
  4. Create the connector using one of the following options:

    For more details and optional arguments, see thegcloudreference.

    • Create a connector using an existing subnet:

      gcloudcomputenetworksvpc-accessconnectorscreateCONNECTOR_NAME\--regionREGION\--subnetSUBNET_NAME\--subnet-projectHOST_PROJECT_ID\--min-instancesMIN\--max-instancesMAX\--machine-typeMACHINE_TYPE

      Replace the following:

      • CONNECTOR_NAME: a name for your connector,matching Compute Enginenamingconventions,with the additional requirements that the name must be less than 21characters long, and that hyphens (-) count as two characters.
      • REGION: a region for your connector, matching theregion of your serverless service or job. If your service or job isinus-central oreurope-west, useus-central1 oreurope-west1.
      • SUBNET_NAME: the name of the existing subnet.
      • HOST_PROJECT_ID: the Shared VPC hostproject ID. If the connector and existing subnet are located thesame project, omit the--subnet-project flag.
      • MIN: the minimum number of instances to use forthe connector. Use an integer between2(the default) and9.
      • MAX: the maximum number of instances to use forthe connector. Use an integer between3 and10 (the default).If the connector scales up to the maximum number of instances,itdoes not scale back down.
      • MACHINE_TYPE: must be one of the following:f1-micro,e2-micro, ore2-standard-4.
    • Create a connector and a new subnet:

      gcloudcomputenetworksvpc-accessconnectorscreateCONNECTOR_NAME\--regionREGION\--networkVPC_NETWORK\--rangeIP_RANGE--min-instancesMIN\--max-instancesMAX\--machine-typeMACHINE_TYPE

      Replace the following:

      • CONNECTOR_NAME: a name for your connector,matching Compute Enginenamingconventions,with the additional requirements that the name must be less than 21characters long, and that hyphens (-) count as two characters.
      • REGION: a region for your connector, matching theregion of your serverless service or job. If your service or job isinus-central oreurope-west, useus-central1 oreurope-west1.
      • VPC_NETWORK: the name of the VPCnetwork to attach your connector to. The connector andVPC network must be located in the same project.
      • IP_RANGE: provide an unused/28 CIDR (forexample10.8.0.0/28) to use as the primary IPv4 address rangeof a new subnet that Google Cloud creates in the connector'sVPC network. Ensure that the IP range does notconflict with any existing routes in the connector'sVPC network. The name of the new subnet begins withthe "aet-" prefix.
      • MIN: the minimum number of instances to use forthe connector. Use an integer between2(the default) and9.
      • MAX: the maximum number of instances to use forthe connector. Use an integer between3 and10 (the default).If the connector scales up to the maximum number of instances,itdoes not scale back down.
      • MACHINE_TYPE: must be one of the following:f1-micro,e2-micro, ore2-standard-4.
  5. Verify that your connector is in theREADY state before using it:

    gcloudcomputenetworksvpc-accessconnectorsdescribeCONNECTOR_NAME\--regionREGION

    Replace the following:

    • CONNECTOR_NAME: the name of your connector; this isthe name that you specified in the previous step.
    • REGION: the region of your connector; this is theregion that you specified in the previous step.

    The output should contain the linestate: READY.

Terraform

You can use aTerraform resource to enable thevpcaccess.googleapis.com API.

resource "google_project_service" "vpcaccess-api" {  project = var.project_id # Replace this with your project ID in quotes  service = "vpcaccess.googleapis.com"}

You can useTerraform modules to create a VPC network and subnet and then create theconnector.

module "test-vpc-module" {  source       = "terraform-google-modules/network/google"  version      = "~> 13.0"  project_id   = var.project_id # Replace this with your project ID in quotes  network_name = "my-serverless-network"  mtu          = 1460  subnets = [    {      subnet_name   = "serverless-subnet"      subnet_ip     = "10.10.10.0/28"      subnet_region = "us-central1"    }  ]}module "serverless-connector" {  source     = "terraform-google-modules/network/google//modules/vpc-serverless-connector-beta"  version    = "~> 13.0"  project_id = var.project_id  vpc_connectors = [{    name        = "central-serverless"    region      = "us-central1"    subnet_name = module.test-vpc-module.subnets["us-central1/serverless-subnet"].name    # host_project_id = var.host_project_id # Specify a host_project_id for shared VPC    machine_type  = "e2-standard-4"    min_instances = 2    max_instances = 7    }    # Uncomment to specify an ip_cidr_range    #   , {    #     name          = "central-serverless2"    #     region        = "us-central1"    #     network       = module.test-vpc-module.network_name    #     ip_cidr_range = "10.10.11.0/28"    #     subnet_name   = null    #     machine_type  = "e2-standard-4"    #     min_instances = 2    #   max_instances = 7 }  ]  depends_on = [    google_project_service.vpcaccess-api  ]}

Configure your service to use a connector

After you have created a Serverless VPC Access connector,you must configure each service in your App Engine app that you want toconnect to your VPC network.

Note: To deploy a service with a connector, the user or service account doingthe deployment needs theServerless VPC Access UserandCompute ViewerIAM roles.

To specify a connector for a service in your app:

  1. In order to useServerless VPC Access, discontinue the use of theApp Engine URL Fetch service. Serverless VPC Accessdoes not support URL Fetch, and requests made using URL Fetch will ignoreServerless VPC Access settings. Make outbound connections withsocketsinstead.

  2. Add thevpc_access_connector field to your service'sapp.yaml file:

    vpc_access_connector:  name: projects/PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAME

    WherePROJECT_ID is your Google Cloud project ID,REGION is the region your connector is in,andCONNECTOR_NAME is the name of your connector.

  3. Deploy the service:

    gcloudappdeploy

After you deploy your service, it is able to send requests to internal IPaddresses in order to access resources in your VPC network.

Restrict access to VPC resources

Required firewall rules for connectors in service projects

If you create a connector in a standalone VPC network or in thehost project of a Shared VPC network, Google Cloud creates allnecessary firewall rules for the connector's operation. For more information,seeFirewall rules for connectors in standalone VPC networks or Shared VPC host projects.

However, if you create a connector in a service project and the connector targetsa Shared VPC network in the host project, you must add firewall rulesto allow necessary traffic for the connector's operation from the followingranges:

These ranges are used by the Google infrastructure underlyingCloud Run, Cloud Run functions, and App Engine standard environment. All requests fromthese IP addresses originate from Google infrastructure to make surethat each serverless resource only communicates with theconnector that it's connected to.

You must also allow traffic from the connector's subnet to resources in yourVPC network.

To perform these steps, you must have one of the following roles on thehost project:

For a basic configuration, apply the rules to allow serverless resources in anyservice project connected to the Shared VPC network to send requests toany resource in the network.

Important: The rules you create using the following process apply to existingand future connectors that target a given Shared VPC network. If youwant to scope these rules so they only apply to specified connectors, seeCreate firewall rules for specific connectors.

To apply these rules, run the following commands in the host project:

  1. Create firewall rules that allow requests from Google's serverlessinfrastructure and health check probes to reach all connectors in thenetwork. In these commands, UDP and TCP ports are used as proxies and forHTTP health checks, respectively. Don't change the specified ports.

    gcloudcomputefirewall-rulescreateserverless-to-vpc-connector\    --allowtcp:667,udp:665-666,icmp\    --source-ranges=35.199.224.0/19\    --direction=INGRESS\    --target-tagsvpc-connector\    --network=VPC_NETWORK
    gcloudcomputefirewall-rulescreatevpc-connector-to-serverless\    --allowtcp:667,udp:665-666,icmp\    --destination-ranges=35.199.224.0/19\    --direction=EGRESS\    --target-tagsvpc-connector\    --network=VPC_NETWORK
    gcloudcomputefirewall-rulescreatevpc-connector-health-checks\    --allowtcp:667\    --source-ranges=35.191.0.0/16,35.191.192.0/18,130.211.0.0/22\    --direction=INGRESS\    --target-tagsvpc-connector\    --network=VPC_NETWORK

    ReplaceVPC_NETWORK with the name of theVPC network to attach your connector to.

  2. Create an ingress firewall rule on your VPC network to allowrequests from connectors that target this network:

    gcloudcomputefirewall-rulescreatevpc-connector-requests\    --allowtcp,udp,icmp\    --direction=INGRESS\    --source-tagsvpc-connector\    --network=VPC_NETWORK

    This rule gives the connector access to every resource in the network. Tolimit the resources that your serverless environment can reach by usingServerless VPC Access, seeRestrict connector VM access to VPC network resources.

Create firewall rules for specific connectors

Following the procedure inRequired firewall rules for connectors in service projectsresults in firewall rules that apply toall connectors, both current onesand ones created in the future. If you don't want this, but instead want tocreate rules for specific connectors only, you can scope the rules so thatthey apply only to those connectors.

To limit the scope of the rules to specific connectors, you can use one of thefollowing mechanisms:

  • Network tags: Every connector has two network tags:vpc-connector andvpc-connector-REGION-CONNECTOR_NAME.Use the latter format to limit the scope of your firewall rules to a specificconnector.
  • IP ranges: Use this for the egress rules only, because it doesn't work foringress rules. You can use the IP range of the connectorsubnet to limit the scope of your firewall rules to a single VPCconnector.

Restrict connector VM access to VPC network resources

You can restrict your connector's access to resources in its targetVPC network by usingVPC firewallrules or rules infirewallpolicies. You can accomplish theserestrictions using one of the following strategies:

  • Create ingress rules whose targets represent the resources that you wantto limit connector VM access to and whose sources represent the connector VMs.
  • Create egress rules whose targets represent the connector VMs and whosedestinations represent the resources that you want to limit connector VMaccess to.

The following examples illustrate each strategy.

Restrict access using ingress rules

Choose eithernetwork tags orCIDR ranges to control the incoming traffic to your VPC network.

Network tags

The following steps show how to create ingress rules that restrict aconnector's access to your VPC network based on the connectornetwork tags.

  1. Ensure that you have the required permissions to insert firewall rules.You must have one of the followingIdentity and Access Management (IAM) roles:

  2. Deny connector traffic across your VPC network.

    Create an ingress firewall rule with priority lower than 1000 on yourVPC network to deny ingress from the connector networktag. This overrides the implicit firewall rule thatServerless VPC Access creates on your VPCnetwork by default.

    gcloudcomputefirewall-rulescreateRULE_NAME\--action=DENY\--rules=PROTOCOL\--source-tags=VPC_CONNECTOR_NETWORK_TAG\--direction=INGRESS\--network=VPC_NETWORK\--priority=PRIORITY

    Replace the following:

    • RULE_NAME: the name of your new firewall rule. For example,deny-vpc-connector.

    • PROTOCOL: one or more protocols that you want to allow from yourVPC connector. Supported protocols aretcp orudp. For example,tcp:80,udpallows TCP traffic through port 80 and UDP traffic. For more information, seethe documentation for theallowflag.

      For security and validation purposes, you can alsoconfigure deny rules to block traffic for the following unsupportedprotocols:ah,all,esp,icmp,ipip, andsctp.

    • VPC_CONNECTOR_NETWORK_TAG: the universal connector networktag if you want to restrict access for all connectors (including anyconnectors made in the future), or the unique network tag if you want torestrict access for a specific connector.

      • Universal network tag:vpc-connector
      • Unique network tag:vpc-connector-REGION-CONNECTOR_NAME

        Replace:

        • REGION: the region of the connector that you wantto restrict
        • CONNECTOR_NAME: the name of the connector that youwant to restrict

      To learn more about connector network tags, seeNetwork tags.

    • VPC_NETWORK: the name of your VPC network

    • PRIORITY: an integer between 0-65535. For example, 0 sets thehighest priority.

  3. Allow connector traffic to the resource that should receive connectortraffic.

    Use theallow andtarget-tags flags to create an ingress firewallrule targeting the resource in your VPC network that youwant the VPC connector to access. Set the priority forthis rule to be a lower value than the priority of the rule you made inthe previous step.

    gcloudcomputefirewall-rulescreateRULE_NAME\--allow=PROTOCOL\--source-tags=VPC_CONNECTOR_NETWORK_TAG\--direction=INGRESS\--network=VPC_NETWORK\--target-tags=RESOURCE_TAG\--priority=PRIORITY

    Replace the following:

    • RULE_NAME: the name of your new firewall rule. For example,allow-vpc-connector-for-select-resources.

    • PROTOCOL: one or more protocols that you want to allow from yourVPC connector. Supported protocols aretcp orudp. For example,tcp:80,udpallows TCP traffic through port 80 and UDP traffic. For more information, seethe documentation for theallowflag.

    • VPC_CONNECTOR_NETWORK_TAG: the universal connector networktag if you want to restrict access for all connectors (including anyconnectors made in the future), or the unique network tag if you want torestrict access for a specific connector. This must match the networktag that you specified in the previous step.

      • Universal network tag:vpc-connector
      • Unique network tag:vpc-connector-REGION-CONNECTOR_NAME

        Replace:

        • REGION: the region of the connector that you wantto restrict
        • CONNECTOR_NAME: the name of the connector that youwant to restrict

      To learn more about connector network tags, seeNetwork tags.

    • VPC_NETWORK: the name of your VPC network

    • RESOURCE_TAG: the network tag for the VPCresource that you want your VPC connector to access

    • PRIORITY: an integer less than the priority you set inthe previous step. For example, if you set the priority for the ruleyou created in the previous step to 990, try 980.

For more information about the required and optional flags for creatingfirewall rules, refer to thedocumentation forgcloud compute firewall-rules create.

CIDR range

The following steps show how to create ingress rules that restrict aconnector's access to your VPC network based on the connector'sCIDR range.

  1. Ensure that you have the required permissions to insert firewall rules.You must have one of the followingIdentity and Access Management (IAM) roles:

  2. Deny connector traffic across your VPC network.

    Create an ingress firewall rule with priority lower than 1000 on yourVPC network to deny ingress from the connector's CIDRrange. This overrides the implicit firewall rule thatServerless VPC Access creates on your VPCnetwork by default.

    gcloudcomputefirewall-rulescreateRULE_NAME\--action=DENY\--rules=PROTOCOL\--source-ranges=VPC_CONNECTOR_CIDR_RANGE\--direction=INGRESS\--network=VPC_NETWORK\--priority=PRIORITY

    Replace the following:

    • RULE_NAME: the name of your new firewall rule. For example,deny-vpc-connector.

    • PROTOCOL: one or more protocols that you want to allow from yourVPC connector. Supported protocols aretcp orudp. For example,tcp:80,udpallows TCP traffic through port 80 and UDP traffic. For more information, seethe documentation for theallowflag.

      For security and validation purposes, you can alsoconfigure deny rules to block traffic for the following unsupportedprotocols:ah,all,esp,icmp,ipip, andsctp.

    • VPC_CONNECTOR_CIDR_RANGE: the CIDR range for the connectorwhose access you are restricting

    • VPC_NETWORK: the name of your VPC network

    • PRIORITY: an integer between 0-65535. For example, 0 sets thehighest priority.

  3. Allow connector traffic to the resource that should receive connectortraffic.

    Use theallow andtarget-tags flags to create an ingress firewallrule targeting the resource in your VPC network that youwant the VPC connector to access. Set the priority forthis rule to be a lower value than the priority of the rule you made inthe previous step.

    gcloudcomputefirewall-rulescreateRULE_NAME\--allow=PROTOCOL\--source-ranges=VPC_CONNECTOR_CIDR_RANGE\--direction=INGRESS\--network=VPC_NETWORK\--target-tags=RESOURCE_TAG\--priority=PRIORITY

    Replace the following:

    • RULE_NAME: the name of your new firewall rule. For example,allow-vpc-connector-for-select-resources.

    • PROTOCOL: one or more protocols that you want to allow from yourVPC connector. Supported protocols aretcp orudp. For example,tcp:80,udpallows TCP traffic through port 80 and UDP traffic. For more information, seethe documentation for theallowflag.

    • VPC_CONNECTOR_CIDR_RANGE: the CIDR range for the connectoryou whose access you are restricting

    • VPC_NETWORK: the name of your VPC network

    • RESOURCE_TAG: the network tag for the VPCresource that you want your VPC connector to access

    • PRIORITY: an integer less than the priority you set inthe previous step. For example, if you set the priority for the ruleyou created in the previous step to 990, try 980.

For more information about the required and optional flags for creatingfirewall rules, see thedocumentation forgcloud compute firewall-rules create.

Restrict access using egress rules

The following steps show how to create egress rules to restrict connector access.

  1. Ensure that you have the required permissions to insert firewall rules. Youmust have one of the followingIdentity and Access Management (IAM)roles:

  2. Deny egress traffic from your connector.

    Create an egress firewall rule on your Serverless VPC Accessconnector to prevent it from sending outgoing traffic, with the exception ofestablished responses, to any destination.

    gcloudcomputefirewall-rulescreateRULE_NAME\--action=DENY\--rules=PROTOCOL\--direction=EGRESS\--target-tags=VPC_CONNECTOR_NETWORK_TAG\--network=VPC_NETWORK\--priority=PRIORITY

    Replace the following:

    • RULE_NAME: the name of your new firewall rule. For example,deny-vpc-connector.

    • PROTOCOL: one or more protocols that you want to allow from yourVPC connector. Supported protocols aretcp orudp. For example,tcp:80,udpallows TCP traffic through port 80 and UDP traffic. For more information, seethe documentation for theallowflag.

      For security and validation purposes, you can alsoconfigure deny rules to block traffic for the following unsupportedprotocols:ah,all,esp,icmp,ipip, andsctp.

    • VPC_CONNECTOR_NETWORK_TAG: the universal VPCconnector network tag if you want the rule to apply to all existingVPC connectors and any VPC connectors madein the future. Or, the unique VPC connector network tagif you want to control a specific connector.

    • VPC_NETWORK: the name of your VPC network

    • PRIORITY: an integer between 0-65535. For example, 0 sets thehighest priority.

  3. Allow egress traffic when the destination is in the CIDR range that you wantyour connector to access.

    Use theallow anddestination-ranges flags to create a firewall ruleallowing egress traffic from your connector for a specific destination range.Set the destination range to the CIDR range of the resource in yourVPC network that you want your connector to be able to access.Set the priority for this rule to be a lower value than the priority of therule you made in the previous step.

    gcloudcomputefirewall-rulescreateRULE_NAME\--allow=PROTOCOL\--destination-ranges=RESOURCE_CIDR_RANGE\--direction=EGRESS\--network=VPC_NETWORK\--target-tags=VPC_CONNECTOR_NETWORK_TAG\--priority=PRIORITY

    Replace the following:

    • RULE_NAME: the name of your new firewall rule. For example,allow-vpc-connector-for-select-resources.

    • PROTOCOL: one or more protocols that you want to allow from yourVPC connector. Supported protocols aretcp orudp. For example,tcp:80,udpallows TCP traffic through port 80 and UDP traffic. For more information, seethe documentation for theallowflag.

    • RESOURCE_CIDR_RANGE: the CIDR range for the connector whoseaccess you are restricting

    • VPC_NETWORK: the name of your VPC network

    • VPC_CONNECTOR_NETWORK_TAG: the universal VPCconnector network tag if you want the rule to apply to all existingVPC connectors and any VPC connectors madein the future. Or, the unique VPC connector network tagif you want to control a specific connector. If you used the uniquenetwork tag in the previous step, use the unique network tag.

    • PRIORITY: an integer less than the priority you set inthe previous step. For example, if you set the priority for the ruleyou created in the previous step to 990, try 980.

For more information about the required and optional flags for creating firewallrules, refer to thedocumentation forgcloud compute firewall-rules create.

Manage your connector

Controlling egress traffic from a service

By default, only requests to internal IP addresses and internal DNS names arerouted through a Serverless VPC Access connector. You canspecify the egress setting for your service in yourapp.yaml file.

Egress settings are not compatible with the URL Fetch service. If you have notalready done so,disable the URL Fetch defaultand discontinue any explicit use of theurlfetchlibrary. Using theurlfetch library ignores egress settings, and requests will not route through a Serverless VPC Access connector.

To configure the egress behavior of your App Engine service:

  1. Add theegress_setting attribute to thevpc_access_connector field of yourservice'sapp.yaml file:

    vpc_access_connector:name:projects/PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAMEegress_setting:EGRESS_SETTING

    Replace:

    • PROJECT_ID with your Google Cloud project ID
    • REGION with the region your connector is in
    • CONNECTOR_NAME with the name of your connector
    • EGRESS_SETTING with one of the following:
      • private-ranges-only Default. Only requests toRFC 1918 andRFC 6598 IP addressranges or internal DNS names are routed to your VPCnetwork. All other requests are routed directly to the internet.
      • all-traffic All outbound requests from your service arerouted to your VPC network. Requests are then subject tothe firewall, DNS, and routing rules of your VPC network.Note that routing all outbound requests to your VPC networkincreases the amount of egress handled by theServerless VPC Access connector and canincur charges.
  2. Deploy the service:

    gcloudappdeploy

Disconnect a service from a VPC network

To disconnect a service from a VPC network, remove thevpc_access_connector field from theapp.yaml file and re-deploy the service.

Connectors continue to incur charges even if they have no traffic and aredisconnected. For details, seepricing.If you no longer need your connector, be sure todelete it to avoidcontinued billing.

Update a connector

You can update and monitor the following attributes of your connector by usingthe Google Cloud console, Google Cloud CLI, or the API:

  • Machine (instance) type
  • Minimum and maximum number of instances
  • Recent throughput, number of instances, and CPU utilization

Update machine type

Caution: Changing machine type can cause some long-running connections to drop.

Console

  1. Go to the Serverless VPC Access overview page.

    Go to Serverless VPC Access

  2. Select the connector you want to edit and clickEdit.

  3. In theInstance type list, select your preferred machine (instance)type. To learn about available machine types, see the documentation onThroughput and scaling.

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. To update the connector machine type, run the following command in yourterminal:

    gcloudbetacomputenetworksvpc-accessconnectorsupdateCONNECTOR_NAME--region=REGION--machine-type=MACHINE_TYPE
    Replace the following:

    • CONNECTOR_NAME: the name of your connector
    • REGION: the name of your connector's region
    • MACHINE_TYPE: your preferred machine type. Tolearn about available machine types, see the documentation onThroughput and scaling.

Decrease minimum and maximum number of instances

Note: Decreasing the number of instances for existing connectors is notsupported.

To decrease the number of minimum and maximum number of instances, you must dothe following:

  1. Create a new connector with your preferred values.
  2. Update your service or function to use the new connector.
  3. Delete the old connector when you've moved its traffic.

Increase minimum and maximum number of instances

Console

  1. Go to the Serverless VPC Access overview page.

    Go to Serverless VPC Access

  2. Select the connector you want to edit and clickEdit.

  3. In theMinimum instances field, select your preferred minimum number ofinstances.

    The smallest possible value for this field is the current value. Thelargest possible value for this field is the current value in theMaximum instances field minus 1. For example, if the value in theMaximum instances field is 8, then the largest possible value for theMinimum instances field is 7.

  4. In theMaximum instances field, select your preferred maximum number ofinstances.

    The smallest possible value for this field is the current value. Thelargest possible value for this field is 10.

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. To increase the minimum or maximum number of instances for the connector,run the following command in your terminal:

    gcloudbetacomputenetworksvpc-accessconnectorsupdateCONNECTOR_NAME--region=REGION--min-instances=MIN_INSTANCES--max-instances=MAX_INSTANCES
    Replace the following:

  • CONNECTOR_NAME: the name of your connector
  • REGION: the name of your connector's region
  • MIN_INSTANCES: your preferred minimum number ofinstances.
    • Smallest possible value for this field is the current value ofmin_instances. To find the current value, seeFind the current attribute values.
    • Largest possible value for this field is the currentmax_instancesvalue minus 1, becausemin_instances must be less thanmax_instances.For example, ifmax_instances is 8, the largest possible value for thisfield is 7. If your connector uses the defaultmax-instances value of10, the largest possible value of this field is 9. To find the value ofmax-instances, seeFind the current attribute values.
  • MAX_INSTANCES:

    • Smallest possible value for this field is the current value ofmax_instances. To find the current value, seeFind the current attribute values.
    • Largest possible value for this field is 10.

    If you only want to increase the minimum number of instances but not themaximum, you must still specify the maximum number of instances.Conversely, if you only want to update the maximum number of instances butnot the minimum, you must still specify the minimum number of instances.To keep either the minimum or maximum number of instances at their currentvalue, specify their current value. To find their current value, seeFind the current attribute values.

Find the current attribute values

To find the current attribute values for your connector, run the following inyour terminal:

gcloudcomputenetworksvpc-accessconnectorsdescribeCONNECTOR_NAME--region=REGION--project=PROJECT
Replace the following:

  • CONNECTOR_NAME: the name of your connector
  • REGION: the name of your connector's region
  • PROJECT: the name of your Google Cloud project

Monitor connector usage

Monitoring usage over time can help you determine when to adjust a connector'ssettings. For example, if CPU utilization spikes, you might try increasingthe maximum number of instances for better results. Or if you are maxing outthroughput, you might decide to switch to a larger machine type.

To display charts for the connector's throughput, number of instances, and CPUutilization metrics over time by using the Google Cloud console:

  1. Go to the Serverless VPC Access overview page.

    Go to Serverless VPC Access

  2. Click the name of the connector you want to monitor.

  3. Select the number of days you want to display between 1 and 90 days.

  4. In theThroughput chart, hold the pointer over the chart to view the connector'srecent throughput.

  5. In theNumber of instances chart, hold the pointer over the chart to view thenumber of instances recently used by the connector.

  6. In theCPU Utilization chart, hold the pointer over the chart to view theconnector's recent CPU usage. The chart displays the CPU usage distributedacross instances for the 50th, 95th, and 99th percentiles.

Delete a connector

Before you delete a connector, you must remove it from any serverless resourcesthat still use it. Deleting a connector before removing it from your serverlessresources prohibits you from deleting the VPC networklater.

For Shared VPC users who set up connectors in the Shared VPChost project, you can use the commandgcloud compute networks vpc-access connectors describeto list the projects in which there are serverless resources that use a givenconnector.

To delete a connector, use the Google Cloud console or the Google Cloud CLI:

Console

  1. Go to the Serverless VPC Access overview page in theGoogle Cloud console:

    Go to Serverless VPC Access

  2. Select the connector you want to delete.

  3. ClickDelete.

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. Use the followinggcloud command to delete a connector:

    gcloud compute networks vpc-access connectors deleteCONNECTOR_NAME --region=REGION

    Replace the following:

    • CONNECTOR_NAME with the name of the connector you want to delete
    • REGION with the region where the connector is located

Troubleshooting

Service account permissions

To perform operations in your Google Cloud project,Serverless VPC Access uses theServerless VPC Access Service Agent service account. This serviceaccount's email address has the following form:

service-PROJECT_NUMBER@gcp-sa-vpcaccess.iam.gserviceaccount.com

By default, this service account has theServerless VPC Access Service Agent role(roles/vpcaccess.serviceAgent). Serverless VPC Accessoperations may fail if you change this account's permissions.

Poor network performance or high idle CPU utilization

Using a single connector for thousands of instances can cause performancedegradation and elevated idle CPU utilization. To fix this, shard your servicesbetween multiple connectors.

Issues with custom MTU

If you experience issues with a custom MTU, ensure that youuse the default MTU setting for Cloud Run.

Errors

Service account needs Service Agent role error

If you use theRestrict Resource Service Usageorganization policy constraintto block Cloud Deployment Manager (deploymentmanager.googleapis.com), youmight see the following error message:

Serverless VPC Access service account (service-<PROJECT_NUMBER>@gcp-sa-vpcaccess.iam.gserviceaccount.com) needs Serverless VPC Access Service Agent role in the project.

Set the organization policyto either remove Deployment Manager from the denylist or add itto the allowlist.

Connector creation error

If creating a connector results in an error, try the following:

  • Specify anRFC 1918 internal IP range that does not overlap with any existing IP addressreservations in the VPC network.
  • Grant your project permission to use Compute Engine VM images from theproject with IDserverless-vpc-access-images. For more information abouthow to update your organization policy accordingly, seeSet image access constraints.

Unable to access resources

If you specified a connector but still cannot access resources in yourVPC network, make sure that there are no firewall rules on yourVPC network with a priority lower than 1000 that deny ingressfrom your connector's IP address range.

If youconfigure a connector in a Shared VPC service project,make sure that your firewall rulesallow ingress from your serverless infrastructure to the connector.

Connection refused error

If you receiveconnection refused orconnection timeout errors that degradenetwork performance, your connections could be growing without limit acrossinvocations of your serverless application. To limit the maximum number ofconnections used per instance, use a client library that supports connectionpools. For detailed examples of how to use connection pools, seeManage database connections.

Resource not found error

When deleting a VPC network or a firewall rule, you might see amessage that is similar to the following:The resource"aet-uscentral1-subnet--1-egrfw" was not found.

For information about this error and its solution, seeResource not found error in theVPC firewall rules documentation.

Next steps

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.