» google_compute_network_endpoint

A Network endpoint represents a IP address and port combination that is part of a specific network endpoint group (NEG). NEGs are zonals collection of these endpoints for GCP resources within a single subnet. NOTE: Network endpoints cannot be created outside of a network endpoint group.

To get more information about NetworkEndpoint, see:

» Example Usage - Network Endpoint

resource "google_compute_network_endpoint" "default-endpoint" {
  network_endpoint_group = google_compute_network_endpoint_group.neg.name

  instance   = google_compute_instance.endpoint-instance.name
  port       = google_compute_network_endpoint_group.neg.default_port
  ip_address = google_compute_instance.endpoint-instance.network_interface[0].network_ip

data "google_compute_image" "my_image" {
  family  = "debian-9"
  project = "debian-cloud"

resource "google_compute_instance" "endpoint-instance" {
  name         = "endpoint-instance"
  machine_type = "n1-standard-1"

  boot_disk {
    initialize_params {
      image = data.google_compute_image.my_image.self_link

  network_interface {
    subnetwork = google_compute_subnetwork.default.id
    access_config {

resource "google_compute_network_endpoint_group" "group" {
  name         = "my-lb-neg"
  network      = google_compute_network.default.id
  subnetwork   = google_compute_subnetwork.default.id
  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 = ""
  region        = "us-central1"
  network       = google_compute_network.default.id

» Argument Reference

The following arguments are supported:

  • instance - (Required) The name for a specific VM instance that the IP address belongs to. This is required for network endpoints of type GCE_VM_IP_PORT. The instance must be in the same zone of network endpoint group.

  • port - (Required) Port number of network endpoint.

  • ip_address - (Required) IPv4 address of network endpoint. The IP address must belong to a VM in GCE (either the primary IP or as part of an aliased IP range).

  • network_endpoint_group - (Required) The network endpoint group this endpoint is part of.

  • zone - (Optional) Zone where the containing 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:

  • id - an identifier for the resource with format {{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}

» Timeouts

This resource provides the following Timeouts configuration options:

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

» Import

NetworkEndpoint can be imported using any of these accepted formats:

$ terraform import google_compute_network_endpoint.default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
$ terraform import google_compute_network_endpoint.default {{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
$ terraform import google_compute_network_endpoint.default {{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}
$ terraform import google_compute_network_endpoint.default {{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}

» User Project Overrides

This resource supports User Project Overrides.