googleComputeNetworkEndpoint
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
- How-to Guides
- Official Documentation
Example Usage - Network Endpoint
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeNetworkDefault = new google.computeNetwork.ComputeNetwork(
this,
"default",
{
auto_create_subnetworks: false,
name: "neg-network",
}
);
const googleComputeSubnetworkDefault =
new google.computeSubnetwork.ComputeSubnetwork(this, "default_1", {
ip_cidr_range: "10.0.0.1/16",
name: "neg-subnetwork",
network: googleComputeNetworkDefault.id,
region: "us-central1",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeSubnetworkDefault.overrideLogicalId("default");
const dataGoogleComputeImageMyImage =
new google.dataGoogleComputeImage.DataGoogleComputeImage(this, "my_image", {
family: "debian-11",
project: "debian-cloud",
});
const googleComputeInstanceEndpointInstance =
new google.computeInstance.ComputeInstance(this, "endpoint-instance", {
boot_disk: [
{
initialize_params: [
{
image: dataGoogleComputeImageMyImage.selfLink,
},
],
},
],
machine_type: "e2-medium",
name: "endpoint-instance",
network_interface: [
{
access_config: [{}],
subnetwork: googleComputeSubnetworkDefault.id,
},
],
});
new google.computeNetworkEndpoint.ComputeNetworkEndpoint(
this,
"default-endpoint",
{
instance: googleComputeInstanceEndpointInstance.name,
ip_address: `\${${googleComputeInstanceEndpointInstance.networkInterface.fqn}[0].network_ip}`,
network_endpoint_group: "${google_compute_network_endpoint_group.neg.name}",
port: "${google_compute_network_endpoint_group.neg.default_port}",
}
);
new google.computeNetworkEndpointGroup.ComputeNetworkEndpointGroup(
this,
"group",
{
default_port: "90",
name: "my-lb-neg",
network: googleComputeNetworkDefault.id,
subnetwork: googleComputeSubnetworkDefault.id,
zone: "us-central1-a",
}
);
Argument Reference
The following arguments are supported:
-
ipAddress
- (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). -
networkEndpointGroup
- (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. Noteport
is required unless the Network Endpoint Group is created with the type ofgceVmIp
-
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}}/{{networkEndpointGroup}}/{{instance}}/{{ipAddress}}/{{port}}
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.delete
- Default is 20 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.