» google_compute_network_endpoint_group

Network endpoint groups (NEGs) are zonal resources that represent collections of IP address and port combinations for GCP resources within a single subnet. Each IP address and port combination is called a network endpoint.

Network endpoint groups can be used as backends in backend services for HTTP(S), TCP proxy, and SSL proxy load balancers. You cannot use NEGs as a backend with internal load balancers. Because NEG backends allow you to specify IP addresses and ports, you can distribute traffic in a granular fashion among applications or containers running within VM instances.

To get more information about NetworkEndpointGroup, see:

» Example Usage - Network Endpoint Group

resource "google_compute_network_endpoint_group" "neg" {
  name         = "my-lb-neg"
  network      = google_compute_network.default.self_link
  subnetwork   = google_compute_subnetwork.default.self_link
  default_port = "90"
  zone         = "us-central1-a"
}

resource "google_compute_network" "default" {
  name                    = "neg-network"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
  name          = "neg-subnetwork"
  ip_cidr_range = "10.0.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.default.self_link
}

» Argument Reference

The following arguments are supported:

  • name - (Required) Name of the resource; provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

  • network - (Required) The network to which all network endpoints in the NEG belong. Uses "default" project network if unspecified.


  • description - (Optional) An optional description of this resource. Provide this property when you create the resource.

  • network_endpoint_type - (Optional) Type of network endpoints in this network endpoint group. Currently the only supported value is GCE_VM_IP_PORT.

  • subnetwork - (Optional) Optional subnetwork to which all network endpoints in the NEG belong.

  • default_port - (Optional) The default port used if the port number is not specified in the network endpoint.

  • zone - (Optional) Zone where the network endpoint group is located.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • size - Number of network endpoints in the network endpoint group.
  • self_link - The URI of the created resource.

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

NetworkEndpointGroup can be imported using any of these accepted formats:

$ terraform import google_compute_network_endpoint_group.default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}
$ terraform import google_compute_network_endpoint_group.default {{project}}/{{zone}}/{{name}}
$ terraform import google_compute_network_endpoint_group.default {{zone}}/{{name}}
$ terraform import google_compute_network_endpoint_group.default {{name}}

» User Project Overrides

This resource supports User Project Overrides.