» google_compute_instance_group_named_port

Mange the named ports setting for a managed instance group without managing the group as whole. This resource is primarily intended for use with GKE-generated groups that shouldn't otherwise be managed by other tools.

To get more information about InstanceGroupNamedPort, see:

» Example Usage - Instance Group Named Port Gke

resource "google_compute_instance_group_named_port" "my_port" {
  group = google_container_cluster.my_cluster.instance_group_urls[0]
  zone = "us-central1-a"

  name = "http"
  port = 8080
}

resource "google_compute_instance_group_named_port" "my_ports" {
  group = google_container_cluster.my_cluster.instance_group_urls[0]
  zone = "us-central1-a"

  name = "https"
  port = 4443
}

resource "google_compute_network" "container_network" {
  name                    = "container-network"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "container_subnetwork" {
  name                     = "container-subnetwork"
  region                   = "us-central1"
  network                  = google_compute_network.container_network.name
  ip_cidr_range            = "10.0.36.0/24"
}

resource "google_container_cluster" "my_cluster" {
  name               = "my-cluster"
  location           = "us-central1-a"
  initial_node_count = 1

  network    = google_compute_network.container_network.name
  subnetwork = google_compute_subnetwork.container_subnetwork.name

  ip_allocation_policy {
    cluster_ipv4_cidr_block  = "/19"
    services_ipv4_cidr_block = "/22"
  }
}

» Argument Reference

The following arguments are supported:

  • name - (Required) The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.

  • port - (Required) The port number, which can be a value between 1 and 65535.

  • group - (Required) The name of the instance group.


  • zone - (Optional) The zone of the instance group.

  • 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 projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/{{port}}/{{name}}

» Timeouts

This resource provides the following Timeouts configuration options:

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

» Import

InstanceGroupNamedPort can be imported using any of these accepted formats:

$ terraform import google_compute_instance_group_named_port.default projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/{{port}}/{{name}}
$ terraform import google_compute_instance_group_named_port.default {{project}}/{{zone}}/{{group}}/{{port}}/{{name}}
$ terraform import google_compute_instance_group_named_port.default {{zone}}/{{group}}/{{port}}/{{name}}
$ terraform import google_compute_instance_group_named_port.default {{group}}/{{port}}/{{name}}

» User Project Overrides

This resource supports User Project Overrides.