| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Compute Engine" |
| description: |- |
| A Network endpoint represents a IP address and port combination that is |
| part of a specific network endpoint group (NEG). |
| --- |
| |
| # 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 zonal |
| collections 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: |
| |
| * [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/networkEndpointGroups) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/load-balancing/docs/negs/) |
| |
| ## Example Usage - Network Endpoint |
| |
| |
| ```hcl |
| 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-11" |
| project = "debian-cloud" |
| } |
| |
| resource "google_compute_instance" "endpoint-instance" { |
| name = "endpoint-instance" |
| machine_type = "e2-medium" |
| |
| 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 = "10.0.0.1/16" |
| region = "us-central1" |
| network = google_compute_network.default.id |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `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. |
| |
| |
| - - - |
| |
| |
| * `instance` - |
| (Optional) |
| 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` - |
| (Optional) |
| Port number of network endpoint. |
| **Note** `port` is required unless the Network Endpoint Group is created |
| with the type of `GCE_VM_IP` |
| |
| * `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](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| NetworkEndpoint can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}` |
| * `{{project}}/{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}` |
| * `{{zone}}/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}` |
| * `{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import NetworkEndpoint using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/{{instance}}/{{ip_address}}/{{port}}" |
| to = google_compute_network_endpoint.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), NetworkEndpoint can be imported using one of the formats above. For example: |
| |
| ``` |
| $ 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](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |