Skip to content

googleTpuNode

A Cloud TPU instance.

To get more information about Node, see:

Example Usage - TPU Node Basic

/*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 dataGoogleTpuTensorflowVersionsAvailable =
  new google.dataGoogleTpuTensorflowVersions.DataGoogleTpuTensorflowVersions(
    this,
    "available",
    {}
  );
new google.tpuNode.TpuNode(this, "tpu", {
  accelerator_type: "v3-8",
  cidr_block: "10.2.0.0/29",
  name: "test-tpu",
  tensorflow_version: `\${${dataGoogleTpuTensorflowVersionsAvailable.versions.fqn}[0]}`,
  zone: "us-central1-b",
});

Example Usage - TPU Node Full

data "google_tpu_tensorflow_versions" "available" {
}


resource "google_tpu_node" "tpu" {
  name = "test-tpu"
  zone = "us-central1-b"

  accelerator_type = "v3-8"

  tensorflow_version = data.google_tpu_tensorflow_versions.available.versions[0]

  description = "Terraform Google Provider test TPU"
  use_service_networking = true
  network = google_service_networking_connection.private_service_connection.network

  labels = {
    foo = "bar"
  }

  scheduling_config {
    preemptible = true
  }
}

data "google_compute_network" "network" {
  name = "default"
}

resource "google_compute_global_address" "service_range" {
  name          = "tf-test%{random_suffix}"
  purpose       = "VPC_PEERING"
  address_type  = "INTERNAL"
  prefix_length = 16
  network       = data.google_compute_network.network.id
}

resource "google_service_networking_connection" "private_service_connection" {
  network                 = data.google_compute_network.network.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.service_range.name]
}

Argument Reference

The following arguments are supported:

  • name - (Required) The immutable name of the TPU.

  • acceleratorType - (Required) The type of hardware accelerators associated with this node.

  • tensorflowVersion - (Required) The version of Tensorflow running in the Node.


  • description - (Optional) The user-supplied description of the TPU. Maximum of 512 characters.

  • network - (Optional) The name of a network to peer the TPU node to. It must be a preexisting Compute Engine network inside of the project on which this API has been activated. If none is provided, "default" will be used.

  • cidrBlock - (Optional) The CIDR block that the TPU node will use when selecting an IP address. This CIDR block must be a /29 block; the Compute Engine networks API forbids a smaller block, and using a larger block would be wasteful (a node can only consume one IP address). Errors will occur if the CIDR block has already been used for a currently existing TPU node, the CIDR block conflicts with any subnetworks in the user's provided network, or the provided network is peered with another network that is using that CIDR block.

  • useServiceNetworking - (Optional) Whether the VPC peering for the node is set up through Service Networking API. The VPC Peering should be set up before provisioning the node. If this field is set, cidr_block field should not be specified. If the network that you want to peer the TPU Node to is a Shared VPC network, the node must be created with this this field enabled.

  • schedulingConfig - (Optional) Sets the scheduling options for this TPU instance. Structure is documented below.

  • labels - (Optional) Resource labels to represent user provided metadata.

  • zone - (Optional) The GCP location for the TPU. If it is not provided, the provider zone is used.

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

The schedulingConfig block supports:

  • preemptible - (Required) Defines whether the TPU instance is preemptible.

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}}/locations/{{zone}}/nodes/{{name}}

  • serviceAccount - The service account used to run the tensor flow services within the node. To share resources, including Google Cloud Storage data, with the Tensorflow job running in the Node, this account must have permissions to that data.

  • networkEndpoints - The network endpoints where TPU workers can be accessed and sent work. It is recommended that Tensorflow clients of the node first reach out to the first (index 0) entry. Structure is documented below.

The networkEndpoints block contains:

  • ipAddress - (Output) The IP address of this network endpoint.

  • port - (Output) The port of this network endpoint.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

Node can be imported using any of these accepted formats:

$ terraform import google_tpu_node.default projects/{{project}}/locations/{{zone}}/nodes/{{name}}
$ terraform import google_tpu_node.default {{project}}/{{zone}}/{{name}}
$ terraform import google_tpu_node.default {{zone}}/{{name}}
$ terraform import google_tpu_node.default {{name}}

User Project Overrides

This resource supports User Project Overrides.